public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r13-1285] libstdc++: Invert relationship between std::is_clock and std::is_clock_v
Date: Mon, 27 Jun 2022 10:16:37 +0000 (GMT) [thread overview]
Message-ID: <20220627101637.4F41B386C58D@sourceware.org> (raw)
https://gcc.gnu.org/g:48099f7dafe8d10e92ddfc88c0fd5bfbb435d3d6
commit r13-1285-g48099f7dafe8d10e92ddfc88c0fd5bfbb435d3d6
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Jun 23 18:17:30 2022 +0100
libstdc++: Invert relationship between std::is_clock and std::is_clock_v
This redefines std::is_clock in terms of std::is_clock_v, instead of the
other way around. This avoids instantiatng the class template for code
that only uses the variable template.
libstdc++-v3/ChangeLog:
* include/bits/chrono.h (is_clock_v): Define to false.
(is_clock_v<T>): Define partial specialization for true cases.
(is_clock): Define in terms of is_clock_v.
Diff:
---
libstdc++-v3/include/bits/chrono.h | 45 +++++++++++++++-----------------------
1 file changed, 18 insertions(+), 27 deletions(-)
diff --git a/libstdc++-v3/include/bits/chrono.h b/libstdc++-v3/include/bits/chrono.h
index 745f9a81357..05987ca09df 100644
--- a/libstdc++-v3/include/bits/chrono.h
+++ b/libstdc++-v3/include/bits/chrono.h
@@ -273,16 +273,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif // C++17
#if __cplusplus > 201703L
- template<typename _Tp>
- struct is_clock;
-
- template<typename _Tp>
- inline constexpr bool is_clock_v = is_clock<_Tp>::value;
-
#if __cpp_lib_concepts
template<typename _Tp>
- struct is_clock : false_type
- { };
+ inline constexpr bool is_clock_v = false;
template<typename _Tp>
requires requires {
@@ -298,32 +291,30 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
requires same_as<typename _Tp::time_point::duration,
typename _Tp::duration>;
}
- struct is_clock<_Tp> : true_type
- { };
+ inline constexpr bool is_clock_v<_Tp> = true;
#else
template<typename _Tp, typename = void>
- struct __is_clock_impl : false_type
- { };
+ inline constexpr bool is_clock_v = false;
template<typename _Tp>
- struct __is_clock_impl<_Tp,
- void_t<typename _Tp::rep, typename _Tp::period,
- typename _Tp::duration,
- typename _Tp::time_point::duration,
- decltype(_Tp::is_steady),
- decltype(_Tp::now())>>
- : __and_<is_same<typename _Tp::duration,
- duration<typename _Tp::rep, typename _Tp::period>>,
- is_same<typename _Tp::time_point::duration,
- typename _Tp::duration>,
- is_same<decltype(&_Tp::is_steady), const bool*>,
- is_same<decltype(_Tp::now()), typename _Tp::time_point>>::type
- { };
+ inline constexpr bool
+ is_clock_v<_Tp, void_t<typename _Tp::rep, typename _Tp::period,
+ typename _Tp::duration,
+ typename _Tp::time_point::duration,
+ decltype(_Tp::is_steady),
+ decltype(_Tp::now())>>
+ = __and_v<is_same<typename _Tp::duration,
+ duration<typename _Tp::rep, typename _Tp::period>>,
+ is_same<typename _Tp::time_point::duration,
+ typename _Tp::duration>,
+ is_same<decltype(&_Tp::is_steady), const bool*>,
+ is_same<decltype(_Tp::now()), typename _Tp::time_point>>;
+#endif
template<typename _Tp>
- struct is_clock : __is_clock_impl<_Tp>::type
+ struct is_clock
+ : bool_constant<is_clock_v<_Tp>>
{ };
-#endif
#endif // C++20
#if __cplusplus >= 201703L
reply other threads:[~2022-06-27 10:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220627101637.4F41B386C58D@sourceware.org \
--to=redi@gcc.gnu.org \
--cc=gcc-cvs@gcc.gnu.org \
--cc=libstdc++-cvs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).