我有python的附加C++包装器示例:成员函数(方法)是静态的,带有默认参数.所以我使用BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS来定义重载函数.没有编译错误,但是当我调用静态成员函数时,我得到了如下错误:
import boostPythonTest
boostPythonTest.C.method("string")
Run Code Online (Sandbox Code Playgroud)
Run Code Online (Sandbox Code Playgroud)--------------------------------------------------------------------------- ArgumentError Traceback (most recent call last) <ipython-input-4-ab141804179c> in <module>() ----> 1 boostPythonTest.C.method("string") ArgumentError: Python argument types in C.method(str) did not match C++ signature: method(class C {lvalue}, class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >) method(class C {lvalue}, class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >, int) method(class C {lvalue}, class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >, int, bool)
我不明白为什么第一个生成的签名是"class C {lvalue}".如果是这样,静态成员函数需要调用C的实例,它看起来与我相矛盾.
另一方面,我定义了另一个静态成员函数而没有使用成员函数重载,它适用于没有"class C {lvalue}"签名.例如:
boostPythonTest.C.noDefaultArgMethod("string", 0, True)
Run Code Online (Sandbox Code Playgroud)
类型:function String Form:Docstring:noDefaultArgMethod((str)arg1,(int)arg2,(bool)arg3) - > int:
Run Code Online (Sandbox Code Playgroud)C++ signature : int noDefaultArgMethod(class std :: basic_string,class std …