Re: [C++-sig] Raw member and constructor functions
Thanks again! It now works ;-) Sorry for my mistake, I modified the code because I got an conversion error at compilation from tuple to object, but the error was in the member function not in the forwarding function, so I added the extract which was indeed stupid ;-) Thanks again ! Marc "Studious Apprentice" <apprentice_99@hotmail.com> writes:
Thanks a lot for this fast answer ! This looks like the way to go. The following code does compile but the result under python is unexpected :
#include <boost/python.hpp> #include <boost/python/raw_function.hpp> using namespace boost::python;
namespace { class X { public: object memberraw(const tuple& args, const dict& kw) { return make_tuple(args, kw); } };
object memberrawfwd(tuple raw, dict kw) { tuple arg = extract<tuple&>(raw.slice(1, _))();
Why didn't you just do it the way I told you to? Did that fail somehow? This should be tuple arg( raw.slice(1,_) );
return extract<X&>(raw[0])(). memberraw(arg, kw); }
};
BOOST_PYTHON_MODULE(PythonTest) { class_<X>("X") .def("memberraw", raw_function(memberrawfwd)) ; }
-- Dave Abrahams Boost Consulting www.boost-consulting.com _______________________________________________ C++-sig mailing list C++-sig@python.org http://mail.python.org/mailman/listinfo/c++-sig
"Studious Apprentice" <apprentice_99@hotmail.com> writes:
Thanks again! It now works ;-)
Excellent!
Sorry for my mistake, I modified the code because I got an conversion error at compilation from tuple to object, but the error was in the member function not in the forwarding function,
Probably because object's ctor is explicit. Try using direct initialization (parens) instead of implicit conversion or copy initialization (assignment syntax). -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (2)
-
David Abrahams -
Studious Apprentice