c++: Implement P2582R1, CTAD from inherited constructors
[official-gcc.git] / gcc / testsuite / g++.dg / cpp23 / class-deduction-inherited1.C
blob5fd1270e819d50bb4040f08aa632b2c3013311ac
1 // Modified example from P2582R1
2 // { dg-do compile { target c++23 } }
4 template <typename T> struct B {
5   B(T);
6 };
7 B(bool) -> B<char>;
8 template <typename T> struct C : public B<T> {
9   using B<T>::B;
11 template <typename T> struct D : public B<T> {};
13 C c(42);            // OK, deduces C<int>
14 using ty1 = decltype(c);
15 using ty1 = C<int>;
17 D d(42);            // { dg-error "deduction|no match" }
19 C c2(true);           // OK, deduces C<char>
20 using ty2 = decltype(c2);
21 using ty2 = C<char>;
23 template <typename T> struct E : public B<int> {
24   using B<int>::B;
27 E e(42);            // { dg-error "deduction|no match" }
29 template <typename T, typename U, typename V> struct F {
30   F(T, U, V);
32 template <typename T, typename U> struct G : F<U, T, int> {
33   using F<U, T, int>::F;
36 G g(true, 'a', 1);  // OK, deduces G<char, bool>
37 using ty3 = decltype(g);
38 using ty3 = G<char, bool>;