Irrlicht、dimension2df から次の関数を登録しようとしています。
template <class U>
dimension2d<T>& operator=(const dimension2d<U>& other)
{
Width = (T) other.Width;
Height = (T) other.Height;
return *this;
}
完全なソース ファイルは次のとおりです: http://irrlicht.sourceforge.net/docu/dimension2d_8h_source.html
これは、オーバーロードされた operator= を angelscript に登録するための私の C++ コードです。
r = engine->RegisterObjectMethod("dimension2f", "bool opEquals(const dimension2f &in) const", asFUNCTIONPR(operator==, (dimension2df&), bool),asCALL_CDECL_OBJFIRST); assert(r >= 0);
コンパイルすると、次のエラー メッセージが表示されます。
E:\pb\main.cpp|295|error: invalid static_cast from type '<unresolved overloaded function type>' to type 'bool (*)(irr::core::dimension2df&)'|
ドキュメントを見ると、演算子関数を登録するためのこの方法が説明されています。
struct Vector3
{
Vector3();
Vector3(const Vector3 &other);
Vector3(float x, float y, float z);
Vector3 &operator=(const Vector3 &other);
Vector3 &operator+=(const Vector3 &other);
Vector3 &operator-=(const Vector3 &other);
Vector3 &operator*=(float scalar);
Vector3 &operator/=(float scalar);
friend bool operator==(const Vector3 &a, const Vector3 &b);
friend bool operator!=(const Vector3 &a, const Vector3 &b);
friend Vector3 operator+(const Vector3 &a, const Vector3 &b);
friend Vector3 operator-(const Vector3 &a, const Vector3 &b);
friend Vector3 operator*(float s, const Vector3 &v);
friend Vector3 operator*(const Vector3 &v, float s);
friend Vector3 operator/(const Vector3 &v, float s);
float x;
float y;
float z;
};
r = engine->RegisterObjectMethod("vector3", "bool opEquals(const vector3 &in) const", asFUNCTIONPR(operator==, (const Vector3&, const Vector3&), bool), asCALL_CDECL_OBJFIRST); assert( r >= 0 );
この例に可能な限り忠実に従おうとしましたが、この問題に本当に困惑しました。