2011-11-28 37 views
5

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

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

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

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' 

,最终我得到这一个错误消息酷似的几百份:

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' 

回答

4

是的,有一个限制。 You can find those limits here.它似乎是15,但我相信你可以改变它,根据链接。

+0

非常好,谢谢你的链接!我想知道他们为什么会施加这样的任意限制,如果通过简单地改变限制程序仍然有效...... 我没有找到那个说可以改变这个值的链接的部分,你能指点我好吗? – Derek

+2

@Derek如果没有可变参数模板(在新标准中),您将不得不手动编写每个版本,因此您必须在某处停止。至于在编译不同库(包括扩展模块和Boost.Python库本身)时更改这些数字的能力(使用这些宏的不同值)违反了ODR。但是,我们知道没有任何C++实现可以检测到这种特定的违规行为,或者会导致任何问题。如果实际上无法实现,为什么要提起它? – stonemetal