| 1 |
// PR c++/97099 |
| 2 |
// { dg-do compile { target c++17 } } |
| 3 |
// [temp.deduct.guide]p3: Two deduction guide declarations in the same |
| 4 |
// translation unit for the same class template shall not have equivalent |
| 5 |
// parameter-declaration-clauses. |
| 6 |
|
| 7 |
template<typename> struct S { }; |
| 8 |
template<typename> struct X { }; |
| 9 |
|
| 10 |
S() -> S<int>; // { dg-message "previously defined here|old declaration" } |
| 11 |
S() -> S<int>; // { dg-error "redefinition" } |
| 12 |
X() -> X<int>; |
| 13 |
S() -> S<float>; // { dg-error "ambiguating new declaration of" } |
| 14 |
|
| 15 |
S(bool) -> S<int>; // { dg-message "previously defined here" } |
| 16 |
explicit S(bool) -> S<int>; // { dg-error "redefinition" } |
| 17 |
|
| 18 |
explicit S(char) -> S<int>; // { dg-message "previously defined here" } |
| 19 |
S(char) -> S<int>; // { dg-error "redefinition" } |
| 20 |
|
| 21 |
template<typename T> S(T, T) -> S<int>; // { dg-message "previously declared here" } |
| 22 |
template<typename T> X(T, T) -> X<int>; |
| 23 |
template<typename T> S(T, T) -> S<int>; // { dg-error "redefinition" } |
| 24 |
|
| 25 |
// OK: Use SFINAE. |
| 26 |
template<typename T> S(T) -> S<typename T::foo>; |
| 27 |
template<typename T> S(T) -> S<typename T::bar>; |
| 28 |
|
| 29 |
// OK: Non-template wins. |
| 30 |
S(int) -> S<int>; |
| 31 |
template<typename T = int> S(int) -> S<char>; |