| 1 |
// { dg-do run } |
| 2 |
// Test for partial specialization of a member function template. |
| 3 |
// Origin: Jason Merrill <[email protected]> |
| 4 |
|
| 5 |
template <class T> struct A { |
| 6 |
template <class U> int f(U) { return 42; } |
| 7 |
}; |
| 8 |
|
| 9 |
template <> |
| 10 |
template <class U> |
| 11 |
int A<char>::f(U); |
| 12 |
|
| 13 |
template <> |
| 14 |
template <class U> |
| 15 |
int A<double>::f(U) { return 24; } |
| 16 |
|
| 17 |
int main () |
| 18 |
{ |
| 19 |
A<int> ai; |
| 20 |
if (ai.f(0) != 42) |
| 21 |
return 1; |
| 22 |
|
| 23 |
A<double> ad; |
| 24 |
if (ad.f(0) != 24) |
| 25 |
return 1; |
| 26 |
|
| 27 |
A<char> ac; |
| 28 |
if (ac.f(0) != 36) |
| 29 |
return 1; |
| 30 |
} |
| 31 |
|
| 32 |
template <> |
| 33 |
template <class U> |
| 34 |
int A<char>::f(U) { return 36; } |