From 07a674dc1f00b1e94d47a55bd43c1c9df34cd7b6 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 16 Mar 2021 20:20:16 -0700 Subject: [PATCH 1/3] Use SFINAE for _Is_allocator. Followup to GH 919. Addresses DevCom-1367531. --- stl/inc/sstream | 8 ++++---- stl/inc/xutility | 5 ----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/stl/inc/sstream b/stl/inc/sstream index 90ce15f8ea..51763b89b6 100644 --- a/stl/inc/sstream +++ b/stl/inc/sstream @@ -168,7 +168,7 @@ public: } #if _HAS_CXX20 - template <_Allocator _Alloc2> + template ::value, int> = 0> _NODISCARD basic_string<_Elem, _Traits, _Alloc2> str(const _Alloc2& _Al) const { return basic_string<_Elem, _Traits, _Alloc2>{view(), _Al}; } @@ -632,7 +632,7 @@ public: } #if _HAS_CXX20 - template <_Allocator _Alloc2> + template ::value, int> = 0> _NODISCARD basic_string<_Elem, _Traits, _Alloc2> str(const _Alloc2& _Al) const { return _Stringbuffer.str(_Al); } @@ -752,7 +752,7 @@ public: } #if _HAS_CXX20 - template <_Allocator _Alloc2> + template ::value, int> = 0> _NODISCARD basic_string<_Elem, _Traits, _Alloc2> str(const _Alloc2& _Al) const { return _Stringbuffer.str(_Al); } @@ -878,7 +878,7 @@ public: } #if _HAS_CXX20 - template <_Allocator _Alloc2> + template ::value, int> = 0> _NODISCARD basic_string<_Elem, _Traits, _Alloc2> str(const _Alloc2& _Al) const { return _Stringbuffer.str(_Al); } diff --git a/stl/inc/xutility b/stl/inc/xutility index 2179e1251f..28a06fabfc 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -1459,11 +1459,6 @@ using _Enable_if_execution_policy_t = typename remove_reference_t<_ExPo>::_Stand #endif // _HAS_CXX17 -#if _HAS_CXX20 -template -concept _Allocator = _Is_allocator<_Ty>::value; -#endif // _HAS_CXX20 - // FUNCTION TEMPLATE _Idl_distance template _NODISCARD constexpr auto _Idl_distance(const _Iter& _First, const _Iter& _Last) { From 224702060c9163ddab735290df494be3824624d2 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 16 Mar 2021 22:07:23 -0700 Subject: [PATCH 2/3] Use SFINAE for is_clock. --- stl/inc/chrono | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/stl/inc/chrono b/stl/inc/chrono index 69d0f848fc..c6ae44da15 100644 --- a/stl/inc/chrono +++ b/stl/inc/chrono @@ -58,20 +58,18 @@ namespace chrono { }; #if _HAS_CXX20 + template + struct _Is_clock : false_type {}; + template - concept _Is_clock = requires { - typename _Clock::rep; - typename _Clock::period; - typename _Clock::duration; - typename _Clock::time_point; - _Clock::is_steady; - _Clock::now(); - }; + struct _Is_clock<_Clock, void_t> + : true_type {}; // TRANSITION, GH-602 template - struct is_clock : bool_constant<_Is_clock<_Clock>> {}; + struct is_clock : _Is_clock<_Clock>::type {}; template - inline constexpr bool is_clock_v = _Is_clock<_Clock>; + inline constexpr bool is_clock_v = _Is_clock<_Clock>::value; #endif // _HAS_CXX20 // CLASS TEMPLATE duration From 482df350e4dbd40750c44bd4732a210b86e3c325 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Wed, 17 Mar 2021 02:03:19 -0700 Subject: [PATCH 3/3] Use a variable template for throughput. Co-authored-by: Michael Schellenberger Costa --- stl/inc/chrono | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/stl/inc/chrono b/stl/inc/chrono index c6ae44da15..0744254385 100644 --- a/stl/inc/chrono +++ b/stl/inc/chrono @@ -59,17 +59,18 @@ namespace chrono { #if _HAS_CXX20 template - struct _Is_clock : false_type {}; + inline constexpr bool _Is_clock_v = false; template - struct _Is_clock<_Clock, void_t> - : true_type {}; // TRANSITION, GH-602 + inline constexpr bool + _Is_clock_v<_Clock, void_t> = + true; // TRANSITION, GH-602 template - struct is_clock : _Is_clock<_Clock>::type {}; + struct is_clock : bool_constant<_Is_clock_v<_Clock>> {}; template - inline constexpr bool is_clock_v = _Is_clock<_Clock>::value; + inline constexpr bool is_clock_v = _Is_clock_v<_Clock>; #endif // _HAS_CXX20 // CLASS TEMPLATE duration