Index: include/functional =================================================================== --- include/functional +++ include/functional @@ -1978,6 +1978,7 @@ template struct __ph {}; +#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_BUILDING_BIND) _LIBCPP_FUNC_VIS extern __ph<1> _1; _LIBCPP_FUNC_VIS extern __ph<2> _2; _LIBCPP_FUNC_VIS extern __ph<3> _3; @@ -1988,6 +1989,18 @@ _LIBCPP_FUNC_VIS extern __ph<8> _8; _LIBCPP_FUNC_VIS extern __ph<9> _9; _LIBCPP_FUNC_VIS extern __ph<10> _10; +#else +constexpr __ph<1> _1; +constexpr __ph<2> _2; +constexpr __ph<3> _3; +constexpr __ph<4> _4; +constexpr __ph<5> _5; +constexpr __ph<6> _6; +constexpr __ph<7> _7; +constexpr __ph<8> _8; +constexpr __ph<9> _9; +constexpr __ph<10> _10; +#endif } // placeholders Index: src/bind.cpp =================================================================== --- src/bind.cpp +++ src/bind.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_BUILDING_BIND #include "functional" _LIBCPP_BEGIN_NAMESPACE_STD Index: test/std/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp =================================================================== --- test/std/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp +++ test/std/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp @@ -10,10 +10,29 @@ // // placeholders +// The placeholders are constexpr in C++17 and beyond #include #include +#include "test_macros.h" + +#if TEST_STD_VER > 14 +template +constexpr bool constexpr_test(const T& t) +{ + // Test default constructible. + T t2; + ((void)t2); + // Test copy constructible. + T t3 = t; + ((void)t3); + static_assert(std::is_nothrow_copy_constructible::value, ""); + static_assert(std::is_nothrow_move_constructible::value, ""); + return true; +} +#endif + template void test(const T& t) @@ -40,4 +59,16 @@ test(std::placeholders::_8); test(std::placeholders::_9); test(std::placeholders::_10); +#if TEST_STD_VER > 14 + static_assert(constexpr_test(std::placeholders::_1)); + static_assert(constexpr_test(std::placeholders::_2)); + static_assert(constexpr_test(std::placeholders::_3)); + static_assert(constexpr_test(std::placeholders::_4)); + static_assert(constexpr_test(std::placeholders::_5)); + static_assert(constexpr_test(std::placeholders::_6)); + static_assert(constexpr_test(std::placeholders::_7)); + static_assert(constexpr_test(std::placeholders::_8)); + static_assert(constexpr_test(std::placeholders::_9)); + static_assert(constexpr_test(std::placeholders::_10)); +#endif } Index: www/cxx1z_status.html =================================================================== --- www/cxx1z_status.html +++ www/cxx1z_status.html @@ -161,7 +161,7 @@ 2467is_always_equal has slightly inconsistent defaultLenexaComplete 2470Allocator's destroy function should be allowed to fail to instantiateLenexaComplete 2482[c.strings] Table 73 mentions nonexistent functionsLenexaComplete - 2488Placeholders should be allowed and encouraged to be constexprLenexa + 2488Placeholders should be allowed and encouraged to be constexprLenexaComplete 1169num_get not fully compatible with strto*Kona 2072Unclear wording about capacity of temporary buffersKonaComplete