diff --git a/include/tuple b/include/tuple index b48e2d619..f2a747219 100644 --- a/include/tuple +++ b/include/tuple @@ -1064,11 +1064,13 @@ template struct __ignore_t { template - _LIBCPP_INLINE_VISIBILITY - const __ignore_t& operator=(_Tp&&) const {return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + const __ignore_t& operator=(_Tp&&) const {return *this;} }; -namespace { const __ignore_t ignore = __ignore_t(); } +namespace { + constexpr __ignore_t ignore = __ignore_t(); +} template struct __make_tuple_return_impl diff --git a/test/std/utilities/tuple/tuple.general/ignore.pass.cpp b/test/std/utilities/tuple/tuple.general/ignore.pass.cpp new file mode 100644 index 000000000..8dae3a5dc --- /dev/null +++ b/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. +// +//===----------------------------------------------------------------------===// + +// + +// constexpr unspecified ignore; + +// UNSUPPORTED: c++98, c++03 + +#include +#include + +#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::value, ""); + } +#endif +} diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp index c4c3c242d..5dc98afe6 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp @@ -22,6 +22,24 @@ #include "test_macros.h" +#if TEST_STD_VER > 11 +constexpr bool test_tie_constexpr() { + { + int i = 42; + double f = 1.1; + using ExpectT = std::tuple; + auto res = std::tie(i, std::ignore, f); + static_assert(std::is_same::value, ""); + assert(&std::get<0>(res) == &i); + assert(&std::get<1>(res) == &std::ignore); + assert(&std::get<2>(res) == &f); + // FIXME: If/when tuple gets constexpr assignment + //res = std::make_tuple(101, nullptr, -1.0); + } + return true; +} +#endif + int main() { { @@ -39,5 +57,8 @@ int main() static_assert ( std::get<0>(t) == 42, "" ); static_assert ( std::get<1>(t) == 1.1, "" ); } + { + static_assert(test_tie_constexpr(), ""); + } #endif } diff --git a/www/cxx1z_status.html b/www/cxx1z_status.html index 44f303b94..1a16f8fa1 100644 --- a/www/cxx1z_status.html +++ b/www/cxx1z_status.html @@ -407,7 +407,7 @@ 2767not_fn call_wrapper can form invalid typesIssaquahComplete 2769Redundant const in the return type of any_cast(const any&)IssaquahComplete 2771Broken Effects of some basic_string::compare functions in terms of basic_string_viewIssaquahComplete - 2773Making std::ignore constexprIssaquah + 2773Making std::ignore constexprIssaquahComplete 2777basic_string_view::copy should use char_traits::copyIssaquahComplete 2778basic_string_view is missing constexprIssaquahComplete