brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · 998a88a Raw
72 lines · cpp
1// RUN: %clang_cc1 -std=c++20 -verify %s2// RUN: %clang_cc1 -std=c++23 -verify %s3 4namespace PR52905 {5template <class> concept C = true;6 7struct A {8  int begin();9  int begin() const;10};11 12template <class T>13concept Beginable = requires (T t) {14  { t.begin } -> C;15  // expected-note@-1 {{because 't.begin' would be invalid: reference to non-static member function must be called}}16};17 18static_assert(Beginable<A>); // expected-error {{static assertion failed}}19                             // expected-note@-1 {{does not satisfy 'Beginable'}}20} // namespace PR5290521 22namespace PR52909a {23 24template<class> constexpr bool B = true;25template<class T> concept True = B<T>;26 27template <class T>28int foo(T t) requires requires { // expected-note {{candidate template ignored: constraints not satisfied}}29    {t.begin} -> True; // expected-note {{because 't.begin' would be invalid: reference to non-static member function must be called}}30}31{}32 33struct A { int begin(); };34auto x = foo(A()); // expected-error {{no matching function for call to 'foo'}}35 36} // namespace PR52909a37 38namespace PR52909b {39 40template<class> concept True = true;41 42template<class T> concept C = requires {43    { T::begin } -> True; // expected-note {{because 'T::begin' would be invalid: reference to overloaded function could not be resolved}}44};45 46struct A {47    static void begin(int);48    static void begin(double);49};50 51static_assert(C<A>); // expected-error {{static assertion failed}}52  // expected-note@-1 {{because 'A' does not satisfy 'C'}}53 54} // namespace PR52909b55 56namespace PR53075 {57template<class> concept True = true;58 59template<class T> concept C = requires {60    { &T::f } -> True; // expected-note {{because '&T::f' would be invalid: reference to overloaded function could not be resolved}}61};62 63struct S {64    int *f();65    int *f() const;66};67 68static_assert(C<S>); // expected-error {{static assertion failed}}69  // expected-note@-1 {{because 'S' does not satisfy 'C'}}70 71} // namespace PR5307572