diff --git a/include/algorithm b/include/algorithm index 244ae2d5b..326e566fb 100644 --- a/include/algorithm +++ b/include/algorithm @@ -785,6 +785,7 @@ struct __debug_less __debug_less(_Compare& __c) : __comp_(__c) {} template + _LIBCPP_CONSTEXPR_AFTER_CXX17 bool operator()(const _Tp& __x, const _Up& __y) { bool __r = __comp_(__x, __y); diff --git a/test/libcxx/algorithms/debug_less.pass.cpp b/test/libcxx/algorithms/debug_less.pass.cpp index 260900b7d..5d1b575b5 100644 --- a/test/libcxx/algorithms/debug_less.pass.cpp +++ b/test/libcxx/algorithms/debug_less.pass.cpp @@ -268,6 +268,16 @@ void test_value_categories() { assert(dl(static_cast(1), static_cast(2))); } +#if TEST_STD_VER > 17 +constexpr bool test_constexpr() { + std::less<> cmp{}; + __debug_less > dcmp(cmp); + assert(dcmp(1, 2)); + assert(!dcmp(1, 1)); + return true; +} +#endif + int main(int, char**) { test_passing(); test_failing(); @@ -275,5 +285,8 @@ int main(int, char**) { test_non_const_arg_cmp(); test_value_iterator(); test_value_categories(); +#if TEST_STD_VER > 17 + static_assert(test_constexpr(), ""); +#endif return 0; }