cpptests/templates_partial_specialization.cpp
raw| 1 | template <class T> struct ts {int f(){return 1;}}; |
| 2 | template <> struct ts<int> { |
| 3 | template <class T> struct ns { int f(){return 2;} }; |
| 4 | template <class T> int h(){ return 3; } |
| 5 | }; |
| 6 | |
| 7 | template <> struct ts<int>::ns<int> { int g(){return 0;}; }; // nested and templated struct |
| 8 | template <> int ts<int>::h<int>() { return 0; }; // nested and templated function |
| 9 | |
| 10 | int main () |
| 11 | { |
| 12 | struct ts<int>::ns<int> v; |
| 13 | struct ts<int> w; |
| 14 | return v.g() + w.h<int>(); |
| 15 | } |