[C++-sig] boosting a tuple
Chris Booth
cb9001 at hotmail.com
Mon Jul 15 23:14:28 CEST 2002
Hi all,
I am trying to export a C++ class to python using the boost package
(www.boost.org). I want my C++ functions to return a tuple:
#include "boost/tuple/tuple.hpp"
class TestClass
{
public:
TestClass();
~TestClass();
void setXYZ(float x,float y, float z);
boost::tuples::tuple<float,float,float> getXYZ();
};
And i wrap the class up as follows...
#include <boost/python/class_builder.hpp>
BOOST_PYTHON_MODULE_INIT(Test)
{
boost::python::module_builder TestClass_Module("Test");
boost::python::class_builder<TestClass> pyTestClass(TestClass_Module,
"TestClass");
pyTestClass.def(boost::python::constructor<>());
pyTestClass.def(TestClass::getXYZ, "getXYZ"); // <-- Line #1
pyTestClass.def(TestClass::setXYZ,"setXYZ");
}
if i comment out Line #1, the code compliles to a library that i can import
in python. If i leave this line in, then i get the following error message.
My system is a WindowsXP, MSVC 6.0, boost 1.27.0. Any suggestions would
be really appreciated...
chris
-------------
j:\chrisb\boost_1_27_0\boost\python\detail\extension_class.hpp(393) :
error C2664: 'py_extension_class_converters' : cannot convert
parameter 1 from 'struct boost::python::type<class
boost::tuples::tuple<float,float,float,struct boost::tuples::null_
type,struct boost::tuples::null_type,struct
boost::tuples::null_type,struct boost::tuples::null_type,struct
boost::tuples::null_type,struct boost::tuples::null_type,struct
boost::tuples::null_type> >' to 'struct boost::python::type<class
FasTEMComm>'
No constructor could take the source type, or constructor
overload resolution was ambiguous
j:\chrisb\boost_1_27_0\boost\python\caller.hpp(33) : see
reference to function template instantiation 'struct _object *__cdecl
boost::python::to_python(const class
boost::tuples::tuple<float,float,float,struct
boost::tuples::null_type,struct
boost::tuples::null_type,struct boost::tuples::null_type,struct
boost::tuples::null_type,struct boost::tuples::null_type,struct
boost::tuples::null_type,struct boost::tuples::null_type> &)' being
compiled
j:\chrisb\boost_1_27_0\boost\python\detail\extension_class.hpp(393) :
error C2228: left of '.to_python' must have class/struct/union type
j:\chrisb\boost_1_27_0\boost\python\caller.hpp(33) : see
reference to function template instantiation 'struct _object *__cdecl
boost::python::to_python(const class
boost::tuples::tuple<float,float,float,struct
boost::tuples::null_type,struct
boost::tuples::null_type,struct boost::tuples::null_type,struct
boost::tuples::null_type,struct boost::tuples::null_type,struct
boost::tuples::null_type,struct boost::tuples::null_type> &)' being
compiled
Error executing cl.exe.
--------------------
_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx
More information about the Cplusplus-sig
mailing list