提振.Python多个返回参数
Boost.Python Multiple Return Arguments
我有一个c++函数,从它的参数中返回多个值。
void Do_Something( double input1, double input2, double input3,
double& output1, double& output2 )
{
...
output1 = something;
output2 = something;
}
我想用Boost.Python包装这个函数。我已经提出了一个使用lambdas的解决方案,但它有点乏味,因为我有许多函数在其参数中有多个返回值。
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 );
});
}
在Boost.Python中是否有更好的自动方法来完成此任务?
可以这样改进:
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);
}
相关文章:
- 函数作为模板参数,是否对返回类型强制约束
- 子例程,不使用 pow,并带有参数和返回
- 系统参数信息A 与 SPI_GETMOUSE 返回 0
- 在 c++ 中将函数返回类型指定为模板参数
- 如果返回 -1,时间() 的参数是否被修改?
- 在返回参数列表中C++局部变量(如CodeFights所示)
- is_invocable_r忽略返回参数
- C 功能参数中的返回参数
- 如何在 gmock 中返回参数之一
- 为什么 istream 类的运算符<<在 C++ 中具有引用的返回/参数类型?
- 如果返回参数,是否可以复制省略
- 避免通过引用返回参数
- C/C++ va_list 未正确返回参数
- 返回参数C++的函数
- 为什么在返回参数时不允许RVO
- 如何在createprocess结束后从exe返回参数
- 是否有可能编写一个函数模板来返回参数的数量是否能被N整除?
- 提振.Python多个返回参数
- 伊利德返回参数
- 返回参数的Typename查找