Debian Codegraph @

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

raw
1 // PR c++/66988
2 // { dg-do compile { target c++20 } }
3
4 template<bool B>
5 struct bool_constant {
6 static constexpr bool value = B;
7 constexpr operator bool() const { return value; }
8 };
9
10 using true_type = bool_constant<true>;
11 using false_type = bool_constant<false>;
12
13 template <template <class> class T, class U>
14 concept _Valid = requires { typename T<U>; };
15
16 template <class T>
17 using nested_type = typename T::type;
18
19 template <class T>
20 struct has_nested_type : false_type { };
21
22 template <class T>
23 requires _Valid<nested_type, T>
24 struct has_nested_type<T> : true_type { };
25
26 struct Nested
27 {
28 using type = int;
29 };
30
31 static_assert(!has_nested_type<int>());
32 static_assert(has_nested_type<Nested>());