ThePhD / sol2

Sol3 (sol2 v3.0) - a C++ <-> Lua API wrapper with advanced features and top notch performance - is here, and it's great! Documentation:
http://sol2.rtfd.io/
MIT License
4.06k stars 492 forks source link

Typo in the documentation #1514

Open OndrejPopp opened 11 months ago

OndrejPopp commented 11 months ago

Hi, tx for making this library! I am making a C++ -> Lua bridge from a set of C++ classes I already wrote, and so I did some documentation reading, and found a typo It's over here,

https://sol2.readthedocs.io/en/latest/api/usertype.html#usertype-inheritance

in the statement,

                   ______________ over there B should be A
                 /
lua.new_usertype<B>( "A",
    "call", &A::call
    );

Ok, that was it. Tx!

Ondrej

define SOL_ALL_SAFETIES_ON 1

include <sol/sol.hpp>

struct A { int a = 10; virtual int call() { return 0; } virtual ~A(){} }; struct B : A { int b = 11; virtual int call() override { return 20; } };

int main (int, char*[]) {

sol::state lua;
                    ______________ over there B should be A
                  /
lua.new_usertype<B>( "A",
    "call", &A::call
);

lua.new_usertype<B>( "B",
    "call", &B::call,
    sol::base_classes, sol::bases<A>()
);

return 0;

}