We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am writing a builder-style class. This class is also not copyable.
I want to expose this class in Lua, with a similar builder-style interface.
However, if I have a builder method that returns \*this, kaguya has trouble binding it. But if I change it to a pointer, using this, it works fine.
\*this
this
Not sure if it's a bug or what. It seems like there should be a way to use a reference without making a copy.
Example code:
struct MyBuilder { MyBuilder(int n) : m_n(n) {} // No copies MyBuilder(const MyBuilder &) = delete; MyBuilder &operator=(const MyBuilder &) = delete; // pointer-style MyBuilder *increment_ptr() { ++m_n; return this; } // reference-style MyBuilder &increment() { ++m_n; return *this; } int build() { return m_n; } private: int m_n; }; int main() { kaguya::State state; // C++ usage of builder: // Using references (preferred) MyBuilder(100) .increment() .increment() .build(); // Using pointers MyBuilder(100) .increment_ptr() ->increment_ptr() ->build(); state["MyBuilder"].setClass( kaguya::UserdataMetatable<MyBuilder>() .setConstructors<MyBuilder(int)>() // OK .addFunction("increment_ptr", &MyBuilder::increment_ptr) // no joy. Compiler says: // "use of deleted function ‘MyBuilder::MyBuilder(const MyBuilder&)’" //.addFunction("increment", &MyBuilder::increment) ); return 0; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I am writing a builder-style class.
This class is also not copyable.
I want to expose this class in Lua, with a similar builder-style interface.
However, if I have a builder method that returns
\*this
, kaguya has trouble binding it.But if I change it to a pointer, using
this
, it works fine.Not sure if it's a bug or what.
It seems like there should be a way to use a reference without making a copy.
Example code:
The text was updated successfully, but these errors were encountered: