template struct ts {int f(){return 1;}}; template <> struct ts { template struct ns { int f(){return 2;} }; template int h(){ return 3; } }; template <> struct ts::ns { int g(){return 0;}; }; // nested and templated struct template <> int ts::h() { return 0; }; // nested and templated function int main () { struct ts::ns v; struct ts w; return v.g() + w.h(); }