%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 { template struct Function_ ; template struct ArithFunction ; template class 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 ; }