xref: /llvm-project/clang/test/CXX/over/over.over/p4-2a.cpp (revision 6da3d66f03f9162ef341cc67218be40e22fe9808)
1 // RUN:  %clang_cc1 -std=c++2a -verify %s
2 
3 template<typename T, typename U>
4 constexpr static bool is_same_v = false;
5 
6 template<typename T>
7 constexpr static bool is_same_v<T, T> = true;
8 
9 template<typename T>
10 concept AtLeast2 = sizeof(T) >= 2;
11 
12 template<typename T>
13 concept AtMost8 = sizeof(T) <= 8;
14 
15 template<typename T>
16 struct S {
fooS17 static int foo() requires AtLeast2<long> && AtMost8<long> {
18   return 0;
19 }
20 
fooS21 static double foo() requires AtLeast2<char> {
22   return 0.0;
23 }
24 
barS25 static char bar() requires AtLeast2<char> {
26   return 1.0;
27 }
28 
barS29 static short bar() requires AtLeast2<long> && AtMost8<long> {
30   return 0.0;
31 }
32 
barS33 static int bar() requires AtMost8<long> && AtLeast2<long> {
34   return 0.0;
35 }
36 
bazS37 static char baz() requires AtLeast2<char> {
38   return 1.0;
39 }
40 
bazS41 static short baz() requires AtLeast2<long> && AtMost8<long> {
42   return 0.0;
43 }
44 
bazS45 static int baz() requires AtMost8<long> && AtLeast2<long> {
46   return 0.0;
47 }
48 
bazS49 static long baz() requires AtMost8<long> && AtLeast2<long> && AtLeast2<short> {
50   return 3.0;
51 }
52 };
53 
a()54 void a() {
55   static_assert(is_same_v<decltype(&S<int>::foo), int(*)()>);
56   static_assert(is_same_v<decltype(&S<int>::bar), long(*)()>);
57   // expected-error@-1{{reference to overloaded function could not be resolved; did you mean to call it?}}
58   static_assert(is_same_v<decltype(&S<int>::baz), long(*)()>);
59 }
60