EricWF created this revision. EricWF added a reviewer: mclow.lists. EricWF added a subscriber: cfe-commits.
Implement LWG issue #2488 (http://cplusplus.github.io/LWG/lwg-defects.html#2488). http://reviews.llvm.org/D20800 Files: include/functional src/bind.cpp test/std/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp www/cxx1z_status.html
Index: www/cxx1z_status.html =================================================================== --- www/cxx1z_status.html +++ www/cxx1z_status.html @@ -161,7 +161,7 @@ <tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2467">2467</td><td>is_always_equal has slightly inconsistent default</td><td>Lenexa</td><td>Complete</td></tr> <tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2470">2470</td><td>Allocator's destroy function should be allowed to fail to instantiate</td><td>Lenexa</td><td>Complete</td></tr> <tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2482">2482</td><td>[c.strings] Table 73 mentions nonexistent functions</td><td>Lenexa</td><td>Complete</td></tr> - <tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2488">2488</td><td>Placeholders should be allowed and encouraged to be constexpr</td><td>Lenexa</td><td></td></tr> + <tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2488">2488</td><td>Placeholders should be allowed and encouraged to be constexpr</td><td>Lenexa</td><td>Complete</td></tr> <tr><td></td><td></td><td></td><td></td></tr> <tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#1169">1169</a></td><td><tt>num_get</tt> not fully compatible with <tt>strto*</tt></td><td>Kona</td><td></td></tr> <tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2072">2072</a></td><td>Unclear wording about capacity of temporary buffers</td><td>Kona</td><td>Complete</td></tr> 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 @@ // <functional> // placeholders +// The placeholders are constexpr in C++17 and beyond #include <functional> #include <type_traits> +#include "test_macros.h" + +#if TEST_STD_VER > 14 +template <class T> +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<T>::value, ""); + static_assert(std::is_nothrow_move_constructible<T>::value, ""); + return true; +} +#endif + template <class T> 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: src/bind.cpp =================================================================== --- src/bind.cpp +++ src/bind.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_BUILDING_BIND #include "functional" _LIBCPP_BEGIN_NAMESPACE_STD Index: include/functional =================================================================== --- include/functional +++ include/functional @@ -1978,6 +1978,7 @@ template <int _Np> 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
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits