%shared_ptr(namespace::class) works, but %shared_ptr(::namespace::class) doesn't work.
A simple example:
example.i:
%module example %include <std_shared_ptr.i> %shared_ptr(::ns::Class) %inline %{ #include <memory> namespace ns { class Class { public: Class() : num(0) {} int get_num() const { return num; } private: int num; }; } // namespace ns std::shared_ptr<::ns::Class> new_class() { return std::shared_ptr<::ns::Class>(new ::ns::Class()); } %}
test.py:
import example ins = example.new_class() print ins.get_num()
The above code only works correctly when I replace "%shared_ptr(::ns::Class)" by "%shared_ptr (ns::Class)".
With currently SWIG git master, the example as written (tweaked for Python3 by adding parentheses to the
print
) gives:If I do: replace "%sharedptr(::ns::Class)" by "%sharedptr (ns::Class)". I get a compilation error instead:
So things seem to have got worse here!
Retesting with current git master I spotted a problem with how I was building the shared library - the reproducer still fails as given, but
s/::ns/ns/g
makes it work. So my "things seem to have got worse" above is bogus.