|
14 | 14 | #include <ranges>
|
15 | 15 | #include <vector>
|
16 | 16 |
|
17 |
| -void test() { |
| 17 | +void test_cv_qualifications() { |
18 | 18 | using R = std::vector<int>;
|
19 |
| - R in = {1, 2, 3}; |
| 19 | + R in = {1, 2, 3}; |
20 | 20 |
|
21 |
| - (void)std::ranges::to<const R>(in); //expected-error-re@*:* {{static assertion failed{{.*}}The target container cannot be const-qualified, please remove the const}} |
22 |
| - (void)(in | std::ranges::to<const R>()); //expected-error-re@*:* {{static assertion failed{{.*}}The target container cannot be const-qualified, please remove the const}} |
23 |
| - (void)std::ranges::to<volatile R>(in); //expected-error-re@*:* {{static assertion failed{{.*}}The target container cannot be volatile-qualified, please remove the volatile}} |
24 |
| - (void)(in | std::ranges::to<volatile R>()); //expected-error-re@*:* {{static assertion failed{{.*}}The target container cannot be volatile-qualified, please remove the volatile}} |
| 21 | + //expected-error-re@*:* {{static assertion failed{{.*}}The target container cannot be const-qualified, please remove the const}} |
| 22 | + (void)std::ranges::to<const R>(in); |
| 23 | + //expected-error-re@*:* {{static assertion failed{{.*}}The target container cannot be const-qualified, please remove the const}} |
| 24 | + (void)(in | std::ranges::to<const R>()); |
| 25 | + |
| 26 | + //expected-error-re@*:* {{static assertion failed{{.*}}The target container cannot be volatile-qualified, please remove the volatile}} |
| 27 | + (void)std::ranges::to<volatile R>(in); |
| 28 | + |
| 29 | + //expected-error-re@*:* {{static assertion failed{{.*}}The target container cannot be volatile-qualified, please remove the volatile}} |
| 30 | + (void)(in | std::ranges::to<volatile R>()); |
| 31 | +} |
| 32 | +//unexpected_types |
| 33 | +void ff(); |
| 34 | +void test_unexpected_types() { |
| 35 | + struct C { |
| 36 | + int member; |
| 37 | + int f(); |
| 38 | + }; |
| 39 | + |
| 40 | + enum color { red, green, blue }; |
| 41 | + using member_func_ptr = decltype(&C::f); |
| 42 | + using member_ptr = decltype(&C::member); |
| 43 | + using func_ptr = decltype(&ff); |
| 44 | + using func_t = decltype(ff); |
| 45 | + |
| 46 | + struct R { |
| 47 | + int* begin() const { return nullptr; }; |
| 48 | + int* end() const { return nullptr; }; |
| 49 | + |
| 50 | + operator int() const; |
| 51 | + operator int*() const; |
| 52 | + operator func_ptr() const; |
| 53 | + operator member_func_ptr() const; |
| 54 | + operator member_ptr() const; |
| 55 | + operator color() const; |
| 56 | + }; |
| 57 | + //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 58 | + (void)std::ranges::to<int>(R{}); |
| 59 | + //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 60 | + (void)(R{} | std::ranges::to<int>()); |
| 61 | + |
| 62 | + //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 63 | + (void)std::ranges::to<int*>(R{}); |
| 64 | + //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 65 | + (void)(R{} | std::ranges::to<int*>()); |
| 66 | + |
| 67 | + //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 68 | + (void)std::ranges::to<func_ptr>(R{}); |
| 69 | + //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 70 | + (void)(R{} | std::ranges::to<func_ptr>()); |
| 71 | + |
| 72 | + //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 73 | + (void)std::ranges::to<member_ptr>(R{}); |
| 74 | + //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 75 | + (void)(R{} | std::ranges::to<member_ptr>()); |
| 76 | + |
| 77 | + //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 78 | + (void)std::ranges::to<func_t>(R{}); |
| 79 | + //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 80 | + (void)(R{} | std::ranges::to<func_t>()); |
| 81 | + |
| 82 | + //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 83 | + (void)std::ranges::to<void>(R{}); |
| 84 | + //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 85 | + //expected-error-re@*:* {{static assertion failed{{.*}}ranges::to: unable to convert to the given container type.}} |
| 86 | + (void)(R{} | std::ranges::to<void>()); |
| 87 | + |
| 88 | + //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 89 | + (void)std::ranges::to<color>(R{}); |
| 90 | + //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 91 | + (void)(R{} | std::ranges::to<color>()); |
25 | 92 | }
|
0 commit comments