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.22k stars 517 forks source link

const-removal and overload #1356

Open maxdemarzi opened 2 years ago

maxdemarzi commented 2 years ago

I think a version of bug https://github.com/ThePhD/sol2/issues/155 has come back:

I have a bunch of overloaded functions that look like this and this works:

        lua.set_function("LinksGetLinks", sol::overload(
            ...
            [this](std::vector<Link> links, const std::string& rel_type) { return this->LinksGetLinksForTypeViaLua(links, rel_type); },
            ));

However if I flip the vector it to "const type&" I get "no matching function call takes this number of arguments and the specified types" just like issue #155 the string is unaffected.

        lua.set_function("LinksGetLinks", sol::overload(
            ....
            [this](const std::vector<Link>& links, const std::string& rel_type) { return this->LinksGetLinksForTypeViaLua(links, rel_type); },
            ));

Is this something that can be fixed or should I just start removing const type& from vectors everywhere?