3

LuaBridge を使用して 2 つのクラスを Lua に公開しようとしています。これらのクラスは次のようになりますSpriteTexture

class Texture
{
public:
    Texture(const std::string& filename);
    ...
}

class Sprite
{
public:
    Sprite(Texture& texture);
    ...
}

今、私はこれらを次のように Lua にバインドしようとしています:

lua_State* L = ...;
luabridge::getGlobalNamespace(L)
    .beginClass<Texture>("Texture") // No ctor exposed, just the class
    .endClass()
    .beginClass<Sprite>("Sprite")
    .addConstructor<void(*)(Texture&)>() // This causes the error
    .endClass();

ただし、これにより次のコンパイル エラーが発生します。

C2664: cannot convert argument 1 from 'const Texture' to 'Texture &'

このエラーが発生する理由と修正方法を教えてください。

4

0 に答える 0