[C++-sig] Nested Boost::Python dictionaries

DarkAnt darkant at gmail.com
Sat May 12 18:22:19 CEST 2012


I'm trying to create a boost::python::dict that stores another
boost::python::dict.

int main()
{
	Py_Initialize();
	boost::python::dict parent;
	try{
		parent["child_dict"] =
boost::make_shared<boost::python::dict>(boost::python::dict());
	}
	catch(...){
		PyErr_Print();
	}
	return 0;
}

TypeError: No to_python (by-value) converter found for C++ type: class
boost::shared_ptr<class boost::python::dict>

I was under the impression that boost::shared_ptr had special
treatment in boost::python(that is the library already knew what to do
with it). I'm not quite sure if I'm supposed to write this to_python
converter or if I'm supposed to achieve this in a different manner. If
I do write the to_python converter what's the method of keeping track
of both reference counts?


More information about the Cplusplus-sig mailing list