Filed as tracker #3462707
    https://sourceforge.net/tracker/index.php?func=detail&aid=3462707&group_id=1645&atid=101645

On Mon, Dec 19, 2011 at 9:02 PM, Justin McCann <jneilm@gmail.com> wrote:

Is this related to bug 3333549?

I had seen some posts related to subclassing, but this one seems a bit different. I guess I'll submit it as a bug/feature request.

That does help; thanks!
     Justin

On Mon, Dec 19, 2011 at 7:05 PM, Johan Hake <johan.hake@gmail.com> wrote:
Try expanding all typedefs in the code swig parses. There is a bug (cannot
remember the url...) for type recognitions of templated, typedefed and
shared_ptred mixed types. You can resolve this by using the whole type names:

%shared_ptr(test::Foo)
%shared_ptr(std::set< boost::shared_ptr<test::Foo> >)
%shared_ptr(boost::shared_ptr<std::set< boost::shared_ptr<test::Foo> > > )

...

%template(FooSet) std::set< boost::shared_ptr<test::Foo> >;

namespace test {
 class Foo {
 public:
   Foo(int i) : val(i);
   Foo(const Foo &j) : val(j.val);
   int val;

 std::set< boost::shared_ptr<Foo> > pset_copy(std::set<
boost::shared_ptr<Foo> > pset);
 boost::shared_ptr<std::set< boost::shared_ptr<Foo> > >
pset_deref(boost::shared_ptr<std::set< boost::shared_ptr<Foo> > > pset);
 boost::shared_ptr<std::set< boost::shared_ptr<Foo> > > get_pset();

 void add_to_pset(boost::shared_ptr<std::set< boost::shared_ptr<Foo> > >
pset, Foo i);
 void add_to_set(std::set< boost::shared_ptr<Foo> > &s, Foo i);

 };

}

Hope this helps you!

Johan

On Tuesday December 20 2011 00:06:15 Justin McCann wrote:
> I am trying to wrap a C++ library which passes around boost::shared_ptr's
> to STL containers (set, map, etc). It was easy enough to wrap
> shared_ptr<Object>, and set<shared_ptr<Object> > and make use of those
> objects and C++ methods from Python, but whenever I try to wrap shared_ptr<
> set < shared_ptr<Object> > >, the object I get back in Python is just a
> SwigPyObject that I can't seem to do anything useful with. Google didn't
> help much.
>
> It seems like I need some sort of combination of %shared_ptr() and
> %template(), but I can't quite figure out how that would work. Is a
> shared_ptr to an STL container supported?
>
> I suppose I could embed some CPython code that would convert between the
> shared_ptr<stl-container> and the Python object, but that just seems ugly
> and would add lots of runtime/copy overhead.
>
> A sample interface file is attached. I can make and modify Foo and FooSet
> objects easily enough. However, the pset_copy, pset_deref, and get_pset
> functions hand me a worthless SwigPyObject in Python. I also can't
> use add_to_pset or add_to_set inside of Python, since any FooSet objects I
> make aren't the right type.
>
> Output from swig version 2.0.4 is below.
>
> Thanks,
>      Justin
>
> ---
> swig -v -debug-classes -python -c++ -Wall -I../include -o test2_wrap.cpp
> test2.i
> Language subdirectory: python
> Search paths:
>    ./
>    ../include/
>    ./swig_lib/python/
>    /opt/local/share/swig/2.0.4/python/
>    ./swig_lib/
>    /opt/local/share/swig/2.0.4/
> Preprocessing...
> Starting language-specific parse...
> Processing types...
> C++ analysis...
> Generating wrappers...
> Classes
> ------------
> std::out_of_range
> std::allocator
> std::invalid_argument
> std::set<(boost::shared_ptr<(test::Foo)>)>
> boost::shared_ptr
> boost::shared_ptr<(test::FooSet_p)>
> boost::shared_ptr<(q(const).test::FooSet_p)>
> boost::shared_ptr<(test::Foo)>
> boost::shared_ptr<(q(const).test::Foo)>
> boost::shared_ptr<(test::FooSet)>
> boost::shared_ptr<(q(const).test::FooSet)>
> std::length_error
> std::exception
> std::domain_error
> std::bad_exception
> std::set
> std::pair<(p.T,U)>
> test::Foo
> std::runtime_error
> std::range_error
> std::overflow_error
> std::logic_error
> std::underflow_error
> std::allocator<(void)>
> std::pair<(T,p.U)>
> std::pair<(p.T,p.U)>
> swig::SwigVar_PyObject
> swig::SwigPtr_PyObject
> std::pair
> swig::SwigPyIterator
> swig::stop_iteration