I have a C++ function that returns multiple values from its arguments.
void Do_Something( double input1, double input2, double input3,
double& output1, double& output2 )
{
...
output1 = something;
output2 = something;
}
I want to wrap this function using Boost.Python. I've come up with a solution using lambdas, but its sort of tedious since I have many functions that have multiple return values in their arguments.
BOOST_PYTHON_MODULE( mymodule )
{
using boost::python;
def( "Do_Something", +[]( double input1, double input2, double input3 )
{
double output1;
double output2;
Do_Something( input1, input2, input3, output1, output2 );
return make_tuple( output1, output2 );
});
}
Is there a better\automatic way to do accomplish this with Boost.Python?
An improvement could be:
boost::python::tuple Do_Something(double input1, double input2,
double input3) {
// Do something
...
return boost::python::make_tuple(output1, output2);
}
BOOST_PYTHON_MODULE(mymodule) {
def("Do_Something", Do_Something);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With