|
6 | 6 | // |
7 | 7 | //===----------------------------------------------------------------------===// |
8 | 8 |
|
9 | | -// <tuple> |
| 9 | +// UNSUPPORTED: c++03 |
10 | 10 |
|
11 | | -// constexpr unspecified ignore; |
| 11 | +// <tuple> |
12 | 12 |
|
13 | | -// UNSUPPORTED: c++03 |
| 13 | +// inline constexpr ignore-type ignore; |
14 | 14 |
|
15 | 15 | #include <cassert> |
| 16 | +#include <cstdint> |
16 | 17 | #include <tuple> |
17 | 18 | #include <type_traits> |
18 | 19 |
|
19 | 20 | #include "test_macros.h" |
20 | 21 |
|
21 | | -constexpr bool test_ignore_constexpr() |
22 | | -{ |
23 | | -#if TEST_STD_VER > 11 |
24 | | - { // Test that std::ignore provides constexpr converting assignment. |
25 | | - auto& res = (std::ignore = 42); |
26 | | - assert(&res == &std::ignore); |
27 | | - } |
28 | | - { // Test that std::ignore provides constexpr copy/move constructors |
29 | | - auto copy = std::ignore; |
30 | | - auto moved = std::move(copy); |
31 | | - ((void)moved); |
32 | | - } |
33 | | - { // Test that std::ignore provides constexpr copy/move assignment |
34 | | - auto copy = std::ignore; |
35 | | - copy = std::ignore; |
36 | | - auto moved = std::ignore; |
37 | | - moved = std::move(copy); |
38 | | - } |
| 22 | +static_assert(std::is_trivial<decltype(std::ignore)>::value, ""); |
| 23 | + |
| 24 | +#if TEST_STD_VER >= 17 |
| 25 | +[[nodiscard]] constexpr int test_nodiscard() { return 8294; } |
39 | 26 | #endif |
40 | | - return true; |
| 27 | + |
| 28 | +TEST_CONSTEXPR_CXX14 bool test() { |
| 29 | + { [[maybe_unused]] auto& ignore_v = std::ignore; } |
| 30 | + |
| 31 | + { // Test that std::ignore provides converting assignment. |
| 32 | + auto& res = (std::ignore = 42); |
| 33 | + static_assert(noexcept(res = (std::ignore = 42)), "Must be noexcept"); |
| 34 | + assert(&res == &std::ignore); |
| 35 | + } |
| 36 | + { // Test bit-field binding. |
| 37 | + struct S { |
| 38 | + unsigned int bf : 3; |
| 39 | + }; |
| 40 | + S s{0b010}; |
| 41 | + auto& res = (std::ignore = s.bf); |
| 42 | + assert(&res == &std::ignore); |
| 43 | + } |
| 44 | + { // Test that std::ignore provides copy/move constructors |
| 45 | + auto copy = std::ignore; |
| 46 | + [[maybe_unused]] auto moved = std::move(copy); |
| 47 | + } |
| 48 | + { // Test that std::ignore provides copy/move assignment |
| 49 | + auto copy = std::ignore; |
| 50 | + copy = std::ignore; |
| 51 | + auto moved = std::ignore; |
| 52 | + moved = std::move(copy); |
| 53 | + } |
| 54 | + |
| 55 | +#if TEST_STD_VER >= 17 |
| 56 | + { std::ignore = test_nodiscard(); } |
| 57 | +#endif |
| 58 | + |
| 59 | + return true; |
41 | 60 | } |
42 | 61 |
|
43 | 62 | int main(int, char**) { |
44 | | - { |
45 | | - constexpr auto& ignore_v = std::ignore; |
46 | | - ((void)ignore_v); |
47 | | - } |
48 | | - { |
49 | | - static_assert(test_ignore_constexpr(), ""); |
50 | | - } |
51 | | - { |
52 | | - LIBCPP_STATIC_ASSERT(std::is_trivial<decltype(std::ignore)>::value, ""); |
53 | | - } |
| 63 | + test(); |
| 64 | +#if TEST_STD_VER >= 14 |
| 65 | + static_assert(test(), ""); |
| 66 | +#endif |
54 | 67 |
|
55 | 68 | return 0; |
56 | 69 | } |
0 commit comments