Boost Python - 包装函数时限制参数的数量

Der*_*rek 6 python boost boost-python

我正在使用Boost Python来包装我创建的一些C++函数.我的一个C++函数包含22个参数.当我尝试用这个函数编译我的解决方案时Boost抱怨,我试图弄清楚它是否只是因为这个函数有太多的参数.

有谁知道这样的限制是否存在?我已经复制了我在下面的错误,而不是代码,因为我认为某人要么知道答案还是没有 - 如果没有限制,那么我只是试着弄清楚自己.首先十分感谢!

这是我收到的错误消息开头的副本...

1>main.cpp

1>c:\cpp_ext\boost\boost_1_47\boost\python\make_function.hpp(76): error C2780: 'boost::mpl::vector17<RT,most_derived<Target,ClassT>::type&,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14> boost::python::detail::get_signature(RT (__thiscall ClassT::* )(T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14) volatile const,Target *)' : expects 2 arguments - 1 provided

1>c:\cpp_ext\boost\boost_1_47\boost\python\signature.hpp(236) : see declaration of 'boost::python::detail::get_signature'
Run Code Online (Sandbox Code Playgroud)

最终我得到了大约一百个与此类似的错误消息:

1>c:\cpp_ext\boost\boost_1_47\boost\python\make_function.hpp(76): error C2784: 'boost::mpl::vector17<RT,ClassT&,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14> boost::python::detail::get_signature(RT (__thiscall ClassT::* )(T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14) volatile const)' : could not deduce template argument for 'RT (__thiscall ClassT::* )(T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14) volatile const' from 'std::string (__cdecl *)(const std::string &,jal::date::JULIAN_DATE,const std::string &,const std::string &,int,const std::string &,const std::string &,const std::string &,const std::string &,const std::string &,const std::string &,int,const std::string &,const std::string &,int,const std::string &,const std::string &,const std::string &,const std::string &,const std::string &,int,const std::string &)'
1>          c:\cpp_ext\boost\boost_1_47\boost\python\signature.hpp(218) : see declaration of 'boost::python::detail::get_signature'
1>c:\cpp_ext\boost\boost_1_47\boost\python\make_function.hpp(76): error C2780: 'boost::mpl::vector17<RT,most_derived<Target,ClassT>::type&,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14> boost::python::detail::get_signature(RT (__thiscall ClassT::* )(T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14) volatile,Target *)' : expects 2 arguments - 1 provided
1>          c:\cpp_ext\boost\boost_1_47\boost\python\signature.hpp(236) : see declaration of 'boost::python::detail::get_signature'
Run Code Online (Sandbox Code Playgroud)

sto*_*tal 6

是的,有一个限制。您可以在此处找到这些限制。 根据链接,它似乎是15,但我相信您可以更改它。

  • @Derek如果没有可变参数模板(在新标准中),您将必须手写每个版本,因此您必须停在某个地方。至于在编译不同的库(包括扩展模块和Boost.Python库本身)时使用这些宏的不同值来更改这些数字的能力,违反了ODR。但是,我们知道没有C ++实现可以检测到这种特殊的违例或引起任何问题。_如果您实际上无法做到这一点,为什么要提出呢? (2认同)