diff options
author | Eric Fiselier <eric@efcs.ca> | 2017-02-06 01:25:31 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2017-02-06 01:25:31 +0000 |
commit | 9af60c4a8b0132ec395c61c93f7d3e2af622a433 (patch) | |
tree | 5585ac50b1ce175c45c2eddbead35c26f2ebd8bd /libcxx/test/std/utilities/tuple/tuple.general | |
parent | 75218fb6b1c979ce4891303c0cf2560639d68033 (diff) | |
download | bcm5719-llvm-9af60c4a8b0132ec395c61c93f7d3e2af622a433.tar.gz bcm5719-llvm-9af60c4a8b0132ec395c61c93f7d3e2af622a433.zip |
Implement LWG 2773 - std::ignore should be constexpr.
In addition to the PR for LWG 2773 this patch also ensures
that each of std::ignores constructors or assignment operators
are constexpr.
llvm-svn: 294165
Diffstat (limited to 'libcxx/test/std/utilities/tuple/tuple.general')
-rw-r--r-- | libcxx/test/std/utilities/tuple/tuple.general/ignore.pass.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/libcxx/test/std/utilities/tuple/tuple.general/ignore.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.general/ignore.pass.cpp new file mode 100644 index 00000000000..8dae3a5dcb0 --- /dev/null +++ b/libcxx/test/std/utilities/tuple/tuple.general/ignore.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <tuple> + +// constexpr unspecified ignore; + +// UNSUPPORTED: c++98, c++03 + +#include <tuple> +#include <cassert> + +#include "test_macros.h" + +constexpr bool test_ignore_constexpr() +{ +#if TEST_STD_VER > 11 + { // Test that std::ignore provides constexpr converting assignment. + auto& res = (std::ignore = 42); + assert(&res == &std::ignore); + } + { // Test that std::ignore provides constexpr copy/move constructors + auto copy = std::ignore; + auto moved = std::move(copy); + ((void)moved); + } + { // Test that std::ignore provides constexpr copy/move assignment + auto copy = std::ignore; + copy = std::ignore; + auto moved = std::ignore; + moved = std::move(copy); + } +#endif + return true; +} + +int main() { + { + constexpr auto& ignore_v = std::ignore; + ((void)ignore_v); + } + { + static_assert(test_ignore_constexpr(), ""); + } +#if defined(_LIBCPP_VERSION) + { + static_assert(std::is_trivial<decltype(std::ignore)>::value, ""); + } +#endif +} |