1 // { dg-do compile { target c++17_only } }
2 // { dg-options "-fconcepts-ts" }
8 concept bool C() { return __is_class(T); }
11 concept bool Type() { return true; }
17 // Basic terse notation
18 void f(auto x) { called = 1; }
19 void g(C x) { called = 2; }
21 // Overloading generic functions
22 void h(auto x) { called = 1; }
23 void h(C x) { called = 2; }
29 void f1(auto x) { called = 1; }
30 void f2(C x) { called = 2; }
32 void f3(auto x) { called = 1; }
33 void f3(C x) { called = 2; }
38 void f1(auto x) { called = 1; }
39 void f2(C x) { called = 2; }
41 void f3(auto x) { called = 1; }
42 void f3(C x) { called = 2; }
51 void g1(T t, U u) { called = 1; }
58 void ptr(C*) { called = 1; }
59 void ptr(const C*) { called = 2; }
61 void ref(C&) { called = 1; }
62 void ref(const C&) { called = 2; }
65 fwd_lvalue_ref(Type&& x) {
66 using T = decltype(x);
67 static_assert(std::is_lvalue_reference<T>::value, "not an lvlaue reference");
71 fwd_const_lvalue_ref(Type&& x) {
72 using T = decltype(x);
73 static_assert(std::is_lvalue_reference<T>::value, "not an lvalue reference");
74 using U = typename std::remove_reference<T>::type;
75 static_assert(std::is_const<U>::value, "not const-qualified");
78 void fwd_rvalue_ref(Type&& x) {
79 using T = decltype(x);
80 static_assert(std::is_rvalue_reference<T>::value, "not an rvalue reference");
83 // Make sure we can use nested names speicifers for concept names.
86 concept bool C() { return true; }
95 f(0); assert(called == 1);
96 g(s); assert(called == 2);
98 h(0); assert(called == 1);
99 h(s); assert(called == 2);
102 s1.f1(0); assert(called == 1);
103 s1.f2(s); assert(called == 2);
105 s1.f3(0); assert(called == 1);
106 s1.f3(s); assert(called == 2);
109 s2.f1(0); assert(called == 1);
110 s2.f2(s); assert(called == 2);
112 s2.f3(0); assert(called == 1);
113 s2.f3(s); assert(called == 2);
115 s2.h1(0); assert(called == 1);
116 s2.h2(s); assert(called == 2);
118 s2.h3(0); assert(called == 1);
119 s2.h3(s); assert(called == 2);
121 s2.g1(s, s); assert(called == 1);
122 s2.g2(s, s); assert(called == 2);
124 ptr(&s); assert(called == 1);
125 ptr(&cs); assert(called == 2);
127 ref(s); assert(called == 1);
128 ref(cs); assert(called == 2);
130 // Check forwarding problems
132 fwd_const_lvalue_ref(cs);
138 // Test that decl/def matching works.
140 void p(auto x) { called = 1; }
141 void p(C x) { called = 2; }
144 void S2<T>::h1(auto x) { called = 1; }
147 void S2<T>::h2(C x) { called = 2; }
150 void S2<T>::h3(auto x) { called = 1; }
153 void S2<T>::h3(C x) { called = 2; }
157 void S2<T>::g2(T t, U u) { called = 2; }