Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/concepts-pr67225-2.C

raw
1 // PR c++/67225
2 // { dg-do compile { target c++20 } }
3 // { dg-additional-options "-fconcepts" }
4
5 template<typename Target>
6 // template<typename Target, typename... Ts>
7 concept has_resize =
8 requires (Target tgt)
9 {
10 { tgt.resize () };
11 };
12
13 template<typename Target>
14 void resize (Target tgt)
15 {
16 if constexpr (has_resize<Target>)
17 {
18 tgt.resize ();
19 }
20 }
21
22 class MyClass
23 {
24 private:
25 int foo (int i)
26 {
27 return i * 2;
28 }
29 };
30
31 int main ()
32 {
33 return MyClass {}.foo (7); // { dg-error "private within this context" }
34 }