|
20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD
|
21 | 21 |
|
22 | 22 | template <class _Compare>
|
23 |
| -struct __debug_less |
24 |
| -{ |
25 |
| - _Compare &__comp_; |
26 |
| - _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI __debug_less(_Compare& __c) : __comp_(__c) {} |
| 23 | +struct __debug_less { |
| 24 | + _Compare& __comp_; |
| 25 | + _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI __debug_less(_Compare& __c) : __comp_(__c) {} |
27 | 26 |
|
28 |
| - template <class _Tp, class _Up> |
29 |
| - _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI |
30 |
| - bool operator()(const _Tp& __x, const _Up& __y) |
31 |
| - { |
32 |
| - bool __r = __comp_(__x, __y); |
33 |
| - if (__r) |
34 |
| - __do_compare_assert(0, __y, __x); |
35 |
| - return __r; |
36 |
| - } |
| 27 | + template <class _Tp, class _Up> |
| 28 | + _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Up& __y) { |
| 29 | + bool __r = __comp_(__x, __y); |
| 30 | + if (__r) |
| 31 | + __do_compare_assert(0, __y, __x); |
| 32 | + return __r; |
| 33 | + } |
37 | 34 |
|
38 |
| - template <class _Tp, class _Up> |
39 |
| - _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI |
40 |
| - bool operator()(_Tp& __x, _Up& __y) |
41 |
| - { |
42 |
| - bool __r = __comp_(__x, __y); |
43 |
| - if (__r) |
44 |
| - __do_compare_assert(0, __y, __x); |
45 |
| - return __r; |
46 |
| - } |
| 35 | + template <class _Tp, class _Up> |
| 36 | + _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(_Tp& __x, _Up& __y) { |
| 37 | + bool __r = __comp_(__x, __y); |
| 38 | + if (__r) |
| 39 | + __do_compare_assert(0, __y, __x); |
| 40 | + return __r; |
| 41 | + } |
47 | 42 |
|
48 |
| - template <class _LHS, class _RHS> |
49 |
| - _LIBCPP_CONSTEXPR_SINCE_CXX14 |
50 |
| - inline _LIBCPP_INLINE_VISIBILITY |
51 |
| - decltype((void)std::declval<_Compare&>()( |
52 |
| - std::declval<_LHS &>(), std::declval<_RHS &>())) |
53 |
| - __do_compare_assert(int, _LHS & __l, _RHS & __r) { |
54 |
| - _LIBCPP_ASSERT_UNCATEGORIZED(!__comp_(__l, __r), |
55 |
| - "Comparator does not induce a strict weak ordering"); |
56 |
| - (void)__l; |
57 |
| - (void)__r; |
58 |
| - } |
| 43 | + template <class _LHS, class _RHS> |
| 44 | + _LIBCPP_CONSTEXPR_SINCE_CXX14 inline _LIBCPP_HIDE_FROM_ABI decltype((void)std::declval<_Compare&>()( |
| 45 | + std::declval<_LHS&>(), std::declval<_RHS&>())) |
| 46 | + __do_compare_assert(int, _LHS& __l, _RHS& __r) { |
| 47 | + _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(!__comp_(__l, __r), "Comparator does not induce a strict weak ordering"); |
| 48 | + (void)__l; |
| 49 | + (void)__r; |
| 50 | + } |
59 | 51 |
|
60 |
| - template <class _LHS, class _RHS> |
61 |
| - _LIBCPP_CONSTEXPR_SINCE_CXX14 |
62 |
| - inline _LIBCPP_INLINE_VISIBILITY |
63 |
| - void __do_compare_assert(long, _LHS &, _RHS &) {} |
| 52 | + template <class _LHS, class _RHS> |
| 53 | + _LIBCPP_CONSTEXPR_SINCE_CXX14 inline _LIBCPP_HIDE_FROM_ABI void __do_compare_assert(long, _LHS&, _RHS&) {} |
64 | 54 | };
|
65 | 55 |
|
66 |
| -// Pass the comparator by lvalue reference. Or in debug mode, using a |
67 |
| -// debugging wrapper that stores a reference. |
68 |
| -#if _LIBCPP_ENABLE_DEBUG_MODE |
| 56 | +// Pass the comparator by lvalue reference. Or in the debug mode, using a debugging wrapper that stores a reference. |
| 57 | +#if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG |
69 | 58 | template <class _Comp>
|
70 | 59 | using __comp_ref_type = __debug_less<_Comp>;
|
71 | 60 | #else
|
|
0 commit comments