I'm having a bit of a tricky issue involving using the std::map accessor functions in Python when this type is represented as a std::shared_ptr type. Specifically, I cannot seem to use the typical [ ] accessor when a type derived from std::map is represented as a shared pointer; however, this doe appear to work when it's simply a regular pointer.
I created a minimum working example to demonstrate the issue.
First, a C++ class declaration, including a class (which I intend to use with a shared_ptr) and then a type I'm deriving from std::map
Finally, the python script I'm using to test things out:
import TestMap as tm
ft = tm.fooType.make_shared() myTestMap = tm.testMap()
myTestMap = ft
When I try to use the accessor function (i.e., myTestMap = ft), I get the following error:
Traceback(most recent call last):File"test_interface.py", line 9,in<module>
File"/home/sskutnik/tstSWIG/TestMap.py", line 217,in __setitem__
return_TestMap.fooMap___setitem__(self,*args)NotImplementedError:Wrong number or type of arguments for overloaded function'fooMap___setitem__'.Possible C/C++ prototypes are:
std::map<int,std::shared_ptr< fooType >>::__setitem__(std::map<int,std::shared_ptr< fooType >>::key_type const&)
std::map<int,std::shared_ptr< fooType >>::__setitem__(std::map<int,std::shared_ptr< fooType >>::key_type const&,std::map<int,std::shared_ptr< fooType >>::mapped_type const&
Note that if I don't include the declaration of testMap (my type derived from std::map) as a shared_ptr, the accessor works perfectly fine.
So, my question is - why does this fail if testMap is declared as a shared_ptr type, and how can I work around this?