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

Error binding global `std::string/std::string_view` or custom string-like usertype with `sol::var` #1549

Open deadlocklogic opened 8 months ago

deadlocklogic commented 8 months ago

Minimal repro:

#define SOL_ALL_SAFETIES_ON 1
#include <sol/sol.hpp>

#include <string>
#include <string_view>

using std::string;
using std::string_view;

string gValueString;
string_view gValueStringView;

void register_tests(sol::state_view& state) {
    state["gValueString"] = sol::var(gValueString);
    state["gValueStringView"] = sol::var(gValueStringView);
}

//

int main() {
    sol::state lua;

    lua.open_libraries(sol::lib::base,
        sol::lib::math,
        sol::lib::bit32,
        sol::lib::package,
        sol::lib::io,
        sol::lib::string,
        sol::lib::table,
        sol::lib::os,
        sol::lib::debug
    );

    register_tests(lua);
}

Error: C2752 'sol::stack::unqualified_pusher<Tu,void>': more than one partial specialization matches the template argument list @ThePhD Is it possible to fix such critical issue, and improve the state of binding global/static variables by reference via std::ref? Again thanks for this awesome library.