Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/concepts-pr82740.C

raw
1 // { dg-do compile { target c++20 } }
2 // { dg-additional-options "-fconcepts" }
3
4 template<class T>
5 concept C = requires(const T& t) { t.foo(); };
6
7 template<class T>
8 struct Base
9 {
10 constexpr T const& derived() const
11 {
12 return static_cast<T const&>(*this);
13 }
14 constexpr bool bar() const
15 requires requires(const T& t) { t.foo(); }
16 {
17 derived().foo();
18 return true;
19 }
20 };
21
22 template<class T>
23 struct Derived : Base<Derived<T>>
24 {
25 constexpr void foo() const {}
26 };
27
28 int main()
29 {
30 static_assert(Derived<int>{}.bar());
31 }
32