|
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 | + (void)std::ranges::to<const R>( |
| 22 | + in); //expected-error-re@*:* {{static assertion failed{{.*}}The target container cannot be const-qualified, please remove the const}} |
| 23 | + (void)(in | |
| 24 | + std::ranges::to< |
| 25 | + const R>()); //expected-error-re@*:* {{static assertion failed{{.*}}The target container cannot be const-qualified, please remove the const}} |
| 26 | + (void)std::ranges::to<volatile R>( |
| 27 | + in); //expected-error-re@*:* {{static assertion failed{{.*}}The target container cannot be volatile-qualified, please remove the volatile}} |
| 28 | + (void)(in | |
| 29 | + std::ranges::to< |
| 30 | + volatile R>()); //expected-error-re@*:* {{static assertion failed{{.*}}The target container cannot be volatile-qualified, please remove the volatile}} |
| 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 | + (void)std::ranges::to<int>( |
| 58 | + R{}); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 59 | + (void)(R{} | std::ranges::to< |
| 60 | + int>()); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 61 | + (void)std::ranges::to<int*>( |
| 62 | + R{}); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 63 | + (void)(R{} | std::ranges::to< |
| 64 | + int*>()); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 65 | + (void)std::ranges::to<func_ptr>( |
| 66 | + R{}); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 67 | + (void)(R{} | |
| 68 | + std::ranges::to< |
| 69 | + func_ptr>()); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 70 | + |
| 71 | + (void)std::ranges::to<member_ptr>( |
| 72 | + R{}); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 73 | + (void)(R{} | |
| 74 | + std::ranges::to< |
| 75 | + member_ptr>()); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 76 | + |
| 77 | + (void)std::ranges::to<func_t>( |
| 78 | + R{}); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 79 | + (void)(R{} | std::ranges::to< |
| 80 | + func_t>()); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 81 | + |
| 82 | + (void)std::ranges::to<void>( |
| 83 | + R{}); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 84 | + (void)(R{} | std::ranges::to< |
| 85 | + void>()); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 86 | + //expected-error-re@*:* {{static assertion failed{{.*}}ranges::to: unable to convert to the given container type.}} |
| 87 | + |
| 88 | + (void)std::ranges::to<color>( |
| 89 | + R{}); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
| 90 | + (void)(R{} | std::ranges::to< |
| 91 | + color>()); //expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}} |
25 | 92 | } |
0 commit comments