2011-11-28 36 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