Skip to content

Commit d3d9735

Browse files
Avoid concepts when __cpp_lib_concepts isn't defined (#1749)
Co-authored-by: Michael Schellenberger Costa <[email protected]>
1 parent 6d5cf9c commit d3d9735

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

stl/inc/chrono

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,19 @@ namespace chrono {
5858
};
5959

6060
#if _HAS_CXX20
61+
template <class _Clock, class = void>
62+
inline constexpr bool _Is_clock_v = false;
63+
6164
template <class _Clock>
62-
concept _Is_clock = requires {
63-
typename _Clock::rep;
64-
typename _Clock::period;
65-
typename _Clock::duration;
66-
typename _Clock::time_point;
67-
_Clock::is_steady;
68-
_Clock::now();
69-
};
65+
inline constexpr bool
66+
_Is_clock_v<_Clock, void_t<typename _Clock::rep, typename _Clock::period, typename _Clock::duration,
67+
typename _Clock::time_point, decltype(_Clock::is_steady), decltype(_Clock::now())>> =
68+
true; // TRANSITION, GH-602
7069

7170
template <class _Clock>
72-
struct is_clock : bool_constant<_Is_clock<_Clock>> {};
71+
struct is_clock : bool_constant<_Is_clock_v<_Clock>> {};
7372
template <class _Clock>
74-
inline constexpr bool is_clock_v = _Is_clock<_Clock>;
73+
inline constexpr bool is_clock_v = _Is_clock_v<_Clock>;
7574
#endif // _HAS_CXX20
7675

7776
// CLASS TEMPLATE duration

stl/inc/sstream

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public:
168168
}
169169

170170
#if _HAS_CXX20
171-
template <_Allocator _Alloc2>
171+
template <class _Alloc2, enable_if_t<_Is_allocator<_Alloc2>::value, int> = 0>
172172
_NODISCARD basic_string<_Elem, _Traits, _Alloc2> str(const _Alloc2& _Al) const {
173173
return basic_string<_Elem, _Traits, _Alloc2>{view(), _Al};
174174
}
@@ -632,7 +632,7 @@ public:
632632
}
633633

634634
#if _HAS_CXX20
635-
template <_Allocator _Alloc2>
635+
template <class _Alloc2, enable_if_t<_Is_allocator<_Alloc2>::value, int> = 0>
636636
_NODISCARD basic_string<_Elem, _Traits, _Alloc2> str(const _Alloc2& _Al) const {
637637
return _Stringbuffer.str(_Al);
638638
}
@@ -752,7 +752,7 @@ public:
752752
}
753753

754754
#if _HAS_CXX20
755-
template <_Allocator _Alloc2>
755+
template <class _Alloc2, enable_if_t<_Is_allocator<_Alloc2>::value, int> = 0>
756756
_NODISCARD basic_string<_Elem, _Traits, _Alloc2> str(const _Alloc2& _Al) const {
757757
return _Stringbuffer.str(_Al);
758758
}
@@ -878,7 +878,7 @@ public:
878878
}
879879

880880
#if _HAS_CXX20
881-
template <_Allocator _Alloc2>
881+
template <class _Alloc2, enable_if_t<_Is_allocator<_Alloc2>::value, int> = 0>
882882
_NODISCARD basic_string<_Elem, _Traits, _Alloc2> str(const _Alloc2& _Al) const {
883883
return _Stringbuffer.str(_Al);
884884
}

stl/inc/xutility

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,11 +1459,6 @@ using _Enable_if_execution_policy_t = typename remove_reference_t<_ExPo>::_Stand
14591459

14601460
#endif // _HAS_CXX17
14611461

1462-
#if _HAS_CXX20
1463-
template <class _Ty>
1464-
concept _Allocator = _Is_allocator<_Ty>::value;
1465-
#endif // _HAS_CXX20
1466-
14671462
// FUNCTION TEMPLATE _Idl_distance
14681463
template <class _Checked, class _Iter>
14691464
_NODISCARD constexpr auto _Idl_distance(const _Iter& _First, const _Iter& _Last) {

0 commit comments

Comments
 (0)