88
99// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
1010
11-
1211// Test that the "mandates" requirements on the given class are checked using `static_assert`.
1312#include < ranges>
14-
13+ void ff () {}
1514void test () {
15+ struct C {
16+ int member;
17+ int f () { return 0 ; }
18+ };
19+
20+ enum color { red, green, blue };
21+ using member_func_ptr = decltype (&C::f);
22+ using member_ptr = decltype (&C::member);
23+ using func_ptr = decltype (&ff);
24+ using func_t = decltype (ff);
25+
1626 struct R {
17- int * begin () const { reurn nullptr ; };
27+ int * begin () const { return nullptr ; };
1828 int * end () const { return nullptr ; };
1929
2030 operator int () const { return 0 ; }
31+ operator int *() const { return nullptr ; }
32+ operator func_ptr () const { return nullptr ; }
33+ operator void () const {}
34+ operator member_func_ptr () const { return nullptr ; }
35+ operator member_ptr () const { return nullptr ; }
36+ operator color () const { return color::red; }
2137 };
22- (void )std::ranges::to<int >(R{});
23- // expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
24- (void )(R{} | std::ranges::to<int >());
25- // expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
26-
38+ (void )std::ranges::to<int >(
39+ R{}); // expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
40+ (void )(R{} | std::ranges::to<
41+ int >()); // expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
42+ (void )std::ranges::to<int *>(
43+ R{}); // expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
44+ (void )(R{} | std::ranges::to<
45+ int *>()); // expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
46+ (void )std::ranges::to<func_ptr>(
47+ R{}); // expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
48+ (void )(R{} |
49+ std::ranges::to<
50+ func_ptr>()); // expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
51+
52+ (void )std::ranges::to<void >(
53+ R{}); // expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
54+ (void )(R{} | std::ranges::to<
55+ void >()); // expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
56+ (void )std::ranges::to<member_ptr>(
57+ R{}); // expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
58+ (void )(R{} |
59+ std::ranges::to<
60+ member_ptr>()); // expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
61+ (void )std::ranges::to<member_func_ptr>(
62+ R{}); // expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
63+ (void )(R{} |
64+ std::ranges::to<
65+ member_func_ptr>()); // expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
66+ (void )std::ranges::to<func_ptr>(
67+ R{}); // expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
68+ (void )(R{} |
69+ std::ranges::to<
70+ func_ptr>()); // expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
71+ (void )std::ranges::to<color>(
72+ R{}); // expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
73+ (void )(R{} | std::ranges::to<
74+ color>()); // expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
75+ (void )std::ranges::to<func_t >(
76+ R{}); // expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
77+ (void )(R{} | std::ranges::to<
78+ func_t >()); // expected-error-re@*:* {{static assertion failed{{.*}}The target must be a class type}}
2779}
0 commit comments