|
19 | 19 |
|
20 | 20 | struct TestType {}; |
21 | 21 |
|
22 | | -void test_const_lvalue_cast_request_non_const_lvalue() |
23 | | -{ |
24 | | - const std::any a; |
25 | | - // expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be a const lvalue reference or a CopyConstructible type}} |
26 | | - // expected-error@any:* {{drops 'const' qualifier}} |
27 | | - (void)std::any_cast<TestType&>(a); // expected-note {{requested here}} |
28 | | - |
29 | | - const std::any a2(42); |
30 | | - // expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be a const lvalue reference or a CopyConstructible type}} |
31 | | - // expected-error@any:* {{drops 'const' qualifier}} |
32 | | - (void)std::any_cast<int&>(a2); // expected-note {{requested here}} |
| 22 | +void test_const_lvalue_cast_request_non_const_lvalue() { |
| 23 | + const std::any a; |
| 24 | + // expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be a const lvalue reference or a CopyConstructible type}} |
| 25 | + // expected-error@any:* {{drops 'const' qualifier}} |
| 26 | + (void)std::any_cast<TestType&>(a); // expected-note {{requested here}} |
| 27 | + |
| 28 | + const std::any a2(42); |
| 29 | + // expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be a const lvalue reference or a CopyConstructible type}} |
| 30 | + // expected-error@any:* {{drops 'const' qualifier}} |
| 31 | + (void)std::any_cast<int&>(a2); // expected-note {{requested here}} |
33 | 32 | } |
34 | 33 |
|
35 | | -void test_lvalue_any_cast_request_rvalue() |
36 | | -{ |
37 | | - std::any a; |
38 | | - // expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be an lvalue reference or a CopyConstructible type}} |
39 | | - (void)std::any_cast<TestType&&>(a); // expected-note {{requested here}} |
| 34 | +void test_lvalue_any_cast_request_rvalue() { |
| 35 | + std::any a; |
| 36 | + // expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be an lvalue reference or a CopyConstructible type}} |
| 37 | + (void)std::any_cast<TestType&&>(a); // expected-note {{requested here}} |
40 | 38 |
|
41 | | - std::any a2(42); |
42 | | - // expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be an lvalue reference or a CopyConstructible type}} |
43 | | - (void)std::any_cast<int&&>(a2); // expected-note {{requested here}} |
| 39 | + std::any a2(42); |
| 40 | + // expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be an lvalue reference or a CopyConstructible type}} |
| 41 | + (void)std::any_cast<int&&>(a2); // expected-note {{requested here}} |
44 | 42 | } |
45 | 43 |
|
46 | | -void test_rvalue_any_cast_request_lvalue() |
47 | | -{ |
48 | | - std::any a; |
49 | | - // expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be an rvalue reference or a CopyConstructible type}} |
50 | | - // expected-error@any:* {{non-const lvalue reference to type 'TestType' cannot bind to a temporary}} |
51 | | - (void)std::any_cast<TestType&>(std::move(a)); // expected-note {{requested here}} |
| 44 | +void test_rvalue_any_cast_request_lvalue() { |
| 45 | + std::any a; |
| 46 | + // expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be an rvalue reference or a CopyConstructible type}} |
| 47 | + // expected-error@any:* {{non-const lvalue reference to type 'TestType' cannot bind to a temporary}} |
| 48 | + (void)std::any_cast<TestType&>(std::move(a)); // expected-note {{requested here}} |
52 | 49 |
|
53 | | - // expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be an rvalue reference or a CopyConstructible type}} |
54 | | - // expected-error@any:* {{non-const lvalue reference to type 'int' cannot bind to a temporary}} |
55 | | - (void)std::any_cast<int&>(42); |
| 50 | + // expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be an rvalue reference or a CopyConstructible type}} |
| 51 | + // expected-error@any:* {{non-const lvalue reference to type 'int' cannot bind to a temporary}} |
| 52 | + (void)std::any_cast<int&>(42); |
56 | 53 | } |
0 commit comments