Debian Codegraph @

gcc/testsuite/g++.dg/template/access41a.C

raw
1 // PR c++/96204
2 // { dg-do compile { target c++14 } }
3 // A variant of access40a.C where has_type_member is a variable template instead
4 // of a class template.
5
6 template<class T>
7 struct A {
8 template<class, class = void>
9 static constexpr bool has_type_member = false;
10 };
11
12 template<class T>
13 template<class U>
14 constexpr int A<T>::has_type_member<U, typename U::type> = true;
15
16 struct Child {
17 private:
18 friend struct A<int>;
19 typedef void type;
20 };
21
22 // The partial specialization matches because A<int> is a friend of Child.
23 static_assert(A<int>::has_type_member<Child>, "");
24 using type1 = const int;
25 using type1 = decltype(A<int>::has_type_member<Child>);
26
27 static_assert(!A<char>::has_type_member<Child>, "");
28 using type2 = const bool;
29 using type2 = decltype(A<char>::has_type_member<Child>);