%module template_ns4 %inline %{ namespace hello { class Double { }; template struct Function { char *test() { return (char *) "test"; } }; template struct ArithFunction : Function { }; template struct traits { }; template struct traits { typedef ArgType arg_type; typedef double res_type; typedef ArithFunction base; }; template struct traits { typedef ArgType arg_type; typedef Double res_type; typedef ArithFunction base; }; template class Class : public ArithFunction< typename traits::arg_type, typename traits::res_type > { }; template typename traits::base make_Class() { return Class(); } } %} namespace hello { // // This complains only when using a namespace // %template() traits; %template(Function_DD) Function ; %template(ArithFunction_DD) ArithFunction ; %template(Class_DD) Class ; %template(make_Class_DD) make_Class ; }