| 1 |
// Modified example from P2582R1 |
| 2 |
// { dg-do compile { target c++23 } } |
| 3 |
|
| 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; |
| 10 |
}; |
| 11 |
template <typename T> struct D : public B<T> {}; |
| 12 |
|
| 13 |
C c(42); // OK, deduces C<int> |
| 14 |
using ty1 = decltype(c); |
| 15 |
using ty1 = C<int>; |
| 16 |
|
| 17 |
D d(42); // { dg-error "deduction|no match" } |
| 18 |
|
| 19 |
C c2(true); // OK, deduces C<char> |
| 20 |
using ty2 = decltype(c2); |
| 21 |
using ty2 = C<char>; |
| 22 |
|
| 23 |
template <typename T> struct E : public B<int> { |
| 24 |
using B<int>::B; |
| 25 |
}; |
| 26 |
|
| 27 |
E e(42); // { dg-error "deduction|no match" } |
| 28 |
|
| 29 |
template <typename T, typename U, typename V> struct F { |
| 30 |
F(T, U, V); |
| 31 |
}; |
| 32 |
template <typename T, typename U> struct G : F<U, T, int> { |
| 33 |
using F<U, T, int>::F; |
| 34 |
}; |
| 35 |
|
| 36 |
G g(true, 'a', 1); // OK, deduces G<char, bool> |
| 37 |
using ty3 = decltype(g); |
| 38 |
using ty3 = G<char, bool>; |