| 1 |
// PR c++/102137 |
| 2 |
// { dg-do compile { target c++17 } } |
| 3 |
|
| 4 |
template<class T> |
| 5 |
struct A { |
| 6 |
constexpr A() { } |
| 7 |
constexpr A(int) { } |
| 8 |
}; |
| 9 |
|
| 10 |
explicit A(...) -> A<int>; |
| 11 |
|
| 12 |
template<template<class> class TT> |
| 13 |
void f() { |
| 14 |
TT x1 = 0; // { dg-error "deduction|no match" } |
| 15 |
TT x2 = {0}; // { dg-error "explicit deduction guide" } |
| 16 |
TT x3(0); |
| 17 |
TT x4{0}; |
| 18 |
TT x5; |
| 19 |
new TT(0); |
| 20 |
new TT{0}; |
| 21 |
new TT(); |
| 22 |
new TT{}; |
| 23 |
new TT; |
| 24 |
} |
| 25 |
|
| 26 |
template<class T> |
| 27 |
void g(T t) { |
| 28 |
A a1 = t; // { dg-error "deduction|no match" } |
| 29 |
A a2 = {t}; // { dg-error "explicit deduction guide" } |
| 30 |
A a3(t); |
| 31 |
A a4{t}; |
| 32 |
A a5; |
| 33 |
new A(t); |
| 34 |
new A{t}; |
| 35 |
} |
| 36 |
|
| 37 |
template void f<A>(); |
| 38 |
template void g(int); |
| 39 |
|
| 40 |
template<template<class> class TT> |
| 41 |
struct B { |
| 42 |
static inline TT x1 = 0; // { dg-error "deduction|no match" } |
| 43 |
static inline TT x2 = {0}; // { dg-error "explicit deduction guide" } |
| 44 |
static inline TT x4{0}; |
| 45 |
static inline TT x5; |
| 46 |
}; |
| 47 |
|
| 48 |
template<class T> |
| 49 |
struct C { |
| 50 |
static inline T t; |
| 51 |
static inline A a1 = t; // { dg-error "deduction|no match" } |
| 52 |
static inline A a2 = {t}; // { dg-error "explicit deduction guide" } |
| 53 |
static inline A a4{t}; |
| 54 |
static inline A a5{}; |
| 55 |
}; |
| 56 |
|
| 57 |
template struct B<A>; |
| 58 |
template struct C<int>; |
| 59 |
|
| 60 |
template<template<class> class TT> |
| 61 |
struct E { |
| 62 |
static constexpr TT x1 = 0; // { dg-error "deduction|no match" } |
| 63 |
static constexpr TT x2 = {0}; // { dg-error "explicit deduction guide" } |
| 64 |
static constexpr TT x4{0}; |
| 65 |
static constexpr TT x5{}; |
| 66 |
}; |
| 67 |
|
| 68 |
template<class T> |
| 69 |
struct F { |
| 70 |
static constexpr T t{}; |
| 71 |
static constexpr A a1 = t; // { dg-error "deduction|no match" } |
| 72 |
static constexpr A a2 = {t}; // { dg-error "explicit deduction guide" } |
| 73 |
static constexpr A a4{t}; |
| 74 |
static constexpr A a5{}; |
| 75 |
}; |
| 76 |
|
| 77 |
template struct E<A>; |
| 78 |
template struct F<int>; |