Boost.Python を使用して C++ クラスの演算子をオーバーロードしようとしています。
thisによると、私は正しい方法でやっています...しかし、コンパイルエラーがたくさんあります。
問題を特定するために作成した簡単な例を次に示します。
#include "boost/python.hpp"
using namespace boost::python;
class number
{
public:
number(int i) : m_Number(i) { }
number operator+(int i) { return number(m_Number + i); }
private:
int m_Number;
};
BOOST_PYTHON_MODULE(test)
{
class_<number>("number", init<int>())
.def(self() + int());
}
コンパイラ エラーは次のとおりです。
Error 1 error C2064: term does not evaluate to a function taking 0 arguments c:\users\kevin\documents\visual studio 2008\projects\boostpythontest\boostpythontest\test.cpp 16 BoostPythonTest
Error 2 error C2780: 'boost::python::class_<W> &boost::python::class_<W>::def(const char *,Fn,const A1 &,const A2 &,const A3 &)' : expects 5 arguments - 1 provided c:\users\kevin\documents\visual studio 2008\projects\boostpythontest\boostpythontest\test.cpp 16 BoostPythonTest
Error 3 error C2780: 'boost::python::class_<W> &boost::python::class_<W>::def(const char *,Fn,const A1 &,const A2 &)' : expects 4 arguments - 1 provided c:\users\kevin\documents\visual studio 2008\projects\boostpythontest\boostpythontest\test.cpp 16 BoostPythonTest
Error 4 error C2780: 'boost::python::class_<W> &boost::python::class_<W>::def(const char *,A1,const A2 &)' : expects 3 arguments - 1 provided c:\users\kevin\documents\visual studio 2008\projects\boostpythontest\boostpythontest\test.cpp 16 BoostPythonTest
Error 5 error C2780: 'boost::python::class_<W> &boost::python::class_<W>::def(const char *,F)' : expects 2 arguments - 1 provided c:\users\kevin\documents\visual studio 2008\projects\boostpythontest\boostpythontest\test.cpp 16 BoostPythonTest
ここで何か不足していますか?
ありがとう