| 1 |
// PR c++/58932 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
|
| 4 |
using nullptr_t = decltype(nullptr); |
| 5 |
|
| 6 |
template<typename T, typename Sfinae = nullptr_t> |
| 7 |
struct B { |
| 8 |
static float& int_if_addable(); |
| 9 |
}; |
| 10 |
|
| 11 |
template<typename T> |
| 12 |
struct B<T, decltype( (T() + T()), nullptr )> { |
| 13 |
static int& int_if_addable(); |
| 14 |
}; |
| 15 |
|
| 16 |
struct X { }; |
| 17 |
|
| 18 |
struct Y { }; |
| 19 |
Y operator+(Y, Y); |
| 20 |
|
| 21 |
struct Z { }; |
| 22 |
Z operator+(Z, Z) = delete; |
| 23 |
|
| 24 |
int main() |
| 25 |
{ |
| 26 |
float& a = B<X>::int_if_addable(); |
| 27 |
int& b = B<Y>::int_if_addable(); |
| 28 |
float& c = B<Z>::int_if_addable(); |
| 29 |
} |