%module xxx %template(abc) SSS::AAA; namespace UUU { struct JJJ; } %template(xxx) UUU::JJJ; %template(TTT_int) VVV::TTT; // needs to be after template is parsed namespace VVV { template struct TTT {}; }