diff options
author | Eric Fiselier <eric@efcs.ca> | 2016-06-26 21:01:34 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2016-06-26 21:01:34 +0000 |
commit | abd892af3a6f46e30681e93eadf449c68b399296 (patch) | |
tree | 9e7c3eb490242e50c723f80b7f2eef56cb4f055c /test/std/utilities | |
parent | 5078baa9e0475783a366e54da37cc9e58f386325 (diff) | |
download | external_libcxx-abd892af3a6f46e30681e93eadf449c68b399296.tar.gz external_libcxx-abd892af3a6f46e30681e93eadf449c68b399296.tar.bz2 external_libcxx-abd892af3a6f46e30681e93eadf449c68b399296.zip |
Implement LWG 2488 - Make the placeholders constexpr.
This patch makes the bind placeholders in std::placeholders both (1) const and
(2) constexpr (See below).
This is technically a breaking change for any code using the placeholders
outside of std::bind and depending on them being non-const. However I don't
think this will break any real world code.
(1) Previously the placeholders were non-const extern globals in all
dialects. This patch changes these extern globals to be const in all dialects.
Since the cv-qualifiers don't participate in name mangling for globals this
is an ABI compatible change.
(2) Make the placeholders constexpr in C++11 and beyond. Although LWG 2488 only
applies to C++17 I don't see any reason not to backport this change.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273824 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/std/utilities')
-rw-r--r-- | test/std/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp index 246186040..68986ac1a 100644 --- a/test/std/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp +++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp @@ -10,10 +10,14 @@ // <functional> // placeholders +// The placeholders are constexpr in C++17 and beyond. +// libc++ provides constexpr placeholders in C++11 and beyond. #include <functional> #include <type_traits> +#include "test_macros.h" + template <class T> void test(const T& t) @@ -28,6 +32,30 @@ test(const T& t) static_assert(std::is_nothrow_move_constructible<T>::value, ""); } +#if TEST_STD_VER >= 11 +constexpr decltype(std::placeholders::_1) default1{}; +constexpr decltype(std::placeholders::_2) default2{}; +constexpr decltype(std::placeholders::_3) default3{}; +constexpr decltype(std::placeholders::_4) default4{}; +constexpr decltype(std::placeholders::_5) default5{}; +constexpr decltype(std::placeholders::_6) default6{}; +constexpr decltype(std::placeholders::_7) default7{}; +constexpr decltype(std::placeholders::_8) default8{}; +constexpr decltype(std::placeholders::_9) default9{}; +constexpr decltype(std::placeholders::_10) default10{}; + +constexpr decltype(std::placeholders::_1) cp1 = std::placeholders::_1; +constexpr decltype(std::placeholders::_2) cp2 = std::placeholders::_2; +constexpr decltype(std::placeholders::_3) cp3 = std::placeholders::_3; +constexpr decltype(std::placeholders::_4) cp4 = std::placeholders::_4; +constexpr decltype(std::placeholders::_5) cp5 = std::placeholders::_5; +constexpr decltype(std::placeholders::_6) cp6 = std::placeholders::_6; +constexpr decltype(std::placeholders::_7) cp7 = std::placeholders::_7; +constexpr decltype(std::placeholders::_8) cp8 = std::placeholders::_8; +constexpr decltype(std::placeholders::_9) cp9 = std::placeholders::_9; +constexpr decltype(std::placeholders::_10) cp10 = std::placeholders::_10; +#endif // TEST_STD_VER >= 11 + int main() { test(std::placeholders::_1); |