| 1 |
// PR c++/37208: SFINAE and deleted functions. |
| 2 |
|
| 3 |
// { dg-do compile { target c++11 } } |
| 4 |
template<int> struct A { }; |
| 5 |
|
| 6 |
template<typename T> |
| 7 |
int& int_if_addable(A<sizeof((*(T*)0) + (*(T*)0))>*); |
| 8 |
|
| 9 |
template<typename T> |
| 10 |
float& int_if_addable(...); |
| 11 |
|
| 12 |
struct X { }; |
| 13 |
|
| 14 |
struct Y { }; |
| 15 |
Y operator+(Y, Y); |
| 16 |
|
| 17 |
struct Z { }; |
| 18 |
Z operator+(Z, Z) = delete; |
| 19 |
|
| 20 |
void f() |
| 21 |
{ |
| 22 |
float& x = int_if_addable<X>(0); |
| 23 |
int& y = int_if_addable<Y>(0); |
| 24 |
float& z = int_if_addable<Z>(0); |
| 25 |
} |