Oberon00 / luabind

Luabind is a library that helps you create bindings between C++ and Lua.
http://oberon00.github.io/luabind/
Other
46 stars 13 forks source link

number_converter class partial specializations not always work correctly. #35

Closed AndriyAstakhov closed 7 years ago

AndriyAstakhov commented 7 years ago

Assume we register standard std::vector class with 'double' elements. C++:

...
class_<std::vector<double>>("vector_double")
    .def(constructor<>())
    .def("push_back", (void(std::vector<double>::*)(const double&))&std::vector<double>::push_back)
...

And then create object of this class in Lua and call push_back() method. Lua:

local vecDouble = vector_double()
vecDouble:push_back(1.5)

As a result we get a runtime error:

Error:
stack: No matching overload found, candidates: void push_back(vector_double&,custom [double] const&)

This code used to work properly before commit '5865097ac9a0ed4431976ce2345c8b6aff9ababa' where branch 'redo-number-converters' was merged. Please note, that the issue occurs with all number types but everything works properly with the same code but using std::string as container element type.

I attach patch that works for me, but it's not cover all platform specific types.

Luabind number_converter patch.txt