%module conversion_ns_template %{ namespace oss { enum Test {One, Two}; template struct Foo { }; template struct Bar { operator int() { return 0; } operator int&() { static int num = 0; return num; } operator Foo() { return Foo(); } operator Foo&() { return *(new Foo()); } }; } %} namespace oss { enum Test {One, Two}; template struct Foo { }; // these two works %rename(hello1) Bar::operator int&(); %ignore Bar::operator int(); // these don't %rename(hello2) Bar::operator Foo&(); %ignore Bar::operator Foo(); template struct Bar { operator int(); operator int&(); operator Foo(); operator Foo&(); }; } namespace oss { %template(Foo_One) Foo; %template(Bar_One) Bar; }