diff --git a/libcxx/include/__algorithm/comp_ref_type.h b/libcxx/include/__algorithm/comp_ref_type.h --- a/libcxx/include/__algorithm/comp_ref_type.h +++ b/libcxx/include/__algorithm/comp_ref_type.h @@ -11,7 +11,7 @@ #include <__config> -#ifdef _LIBCPP_DEBUG +#if _LIBCPP_DEBUG_LEVEL >= 1 # include <__debug> # include <__utility/declval.h> #endif @@ -22,58 +22,49 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#ifdef _LIBCPP_DEBUG +#if _LIBCPP_DEBUG_LEVEL >= 1 template struct __debug_less { _Compare &__comp_; - _LIBCPP_CONSTEXPR_AFTER_CXX17 + _LIBCPP_CONSTEXPR_AFTER_CXX11 __debug_less(_Compare& __c) : __comp_(__c) {} template - _LIBCPP_CONSTEXPR_AFTER_CXX17 - bool operator()(const _Tp& __x, const _Up& __y) - { - bool __r = __comp_(__x, __y); - if (__r) - __do_compare_assert(0, __y, __x); - return __r; + _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _Tp& __x, const _Up& __y) { + bool __r = __comp_(__x, __y); + if (__r) + __do_compare_assert(0, __y, __x); + return __r; } template - _LIBCPP_CONSTEXPR_AFTER_CXX17 - bool operator()(_Tp& __x, _Up& __y) - { - bool __r = __comp_(__x, __y); - if (__r) - __do_compare_assert(0, __y, __x); - return __r; + _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(_Tp& __x, _Up& __y) { + bool __r = __comp_(__x, __y); + if (__r) + __do_compare_assert(0, __y, __x); + return __r; } template - _LIBCPP_CONSTEXPR_AFTER_CXX17 - inline _LIBCPP_INLINE_VISIBILITY - decltype((void)declval<_Compare&>()( - declval<_LHS &>(), declval<_RHS &>())) - __do_compare_assert(int, _LHS & __l, _RHS & __r) { - _LIBCPP_ASSERT(!__comp_(__l, __r), - "Comparator does not induce a strict weak ordering"); + _LIBCPP_CONSTEXPR_AFTER_CXX11 inline _LIBCPP_HIDE_FROM_ABI decltype((void)declval<_Compare&>()(declval<_LHS&>(), + declval<_RHS&>())) + __do_compare_assert(int, _LHS& __l, _RHS& __r) { + _LIBCPP_ASSERT(!__comp_(__l, __r), "Comparator does not induce a strict weak ordering"); } template - _LIBCPP_CONSTEXPR_AFTER_CXX17 - inline _LIBCPP_INLINE_VISIBILITY - void __do_compare_assert(long, _LHS &, _RHS &) {} + _LIBCPP_CONSTEXPR_AFTER_CXX11 inline _LIBCPP_HIDE_FROM_ABI void __do_compare_assert(long, _LHS&, _RHS&) {} }; -#endif // _LIBCPP_DEBUG +#endif // _LIBCPP_DEBUG_LEVEL >= 1 template struct __comp_ref_type { // Pass the comparator by lvalue reference. Or in debug mode, using a // debugging wrapper that stores a reference. -#ifndef _LIBCPP_DEBUG +#if _LIBCPP_DEBUG_LEVEL < 1 typedef _Comp& type; #else typedef __debug_less<_Comp> type; diff --git a/libcxx/test/libcxx/algorithms/debug_less.pass.cpp b/libcxx/test/libcxx/algorithms/debug_less.pass.cpp --- a/libcxx/test/libcxx/algorithms/debug_less.pass.cpp +++ b/libcxx/test/libcxx/algorithms/debug_less.pass.cpp @@ -270,10 +270,10 @@ assert(dl(static_cast(1), static_cast(2))); } -#if TEST_STD_VER > 17 +#if TEST_STD_VER > 11 constexpr bool test_constexpr() { std::less<> cmp{}; - __debug_less > dcmp(cmp); + __debug_less> dcmp(cmp); assert(dcmp(1, 2)); assert(!dcmp(1, 1)); return true; @@ -287,7 +287,7 @@ test_non_const_arg_cmp(); test_value_iterator(); test_value_categories(); -#if TEST_STD_VER > 17 +#if TEST_STD_VER > 11 static_assert(test_constexpr(), ""); #endif return 0;