Debian Codegraph @

gcc/testsuite/g++.dg/diagnostic/static_assert4.C

raw
1 // PR c++/92193
2 // { dg-do compile { target c++11 } }
3
4 template<typename T>
5 struct has_foo
6 { static constexpr bool value = false; };
7
8 template<typename T>
9 #ifndef NO_CONSTEXPR
10 constexpr
11 #endif
12 bool
13 foo(T t) noexcept(noexcept(t.foo()))
14 { return t.foo(); }
15
16 template<typename T>
17 void
18 maybe_foo(T t)
19 {
20 static_assert( has_foo<T>::value, "has foo" ); // { dg-error "has foo" }
21 foo(t);
22 }
23
24 struct X { };
25
26 int main()
27 {
28 X x;
29 maybe_foo(x);
30 }