sol2
sol2 copied to clipboard
Cannot directly bind b2Vec2 to a table entry
Hi, I met with a problem when using sol with box2d.
Box2d has a class called b2Vec2, and I want to set an entry of a table to a b2Vec2.
I tried:
sol::table nt = s.create_table();
nt["a"] = b2Vec2(1, 2);
The compiler then complains an error:
sol.hpp:18406:143: error: no type named ‘function_pointer_type’ in ‘sol::wrapper<b2Vec2, void>::traits_type’ {aka ‘struct sol::lua_bind_traits<b2Vec2>’}
[build] 18406 | return agnostic_lua_call_wrapper<fp_t, is_index, is_variable, checked, boost, clean_stack> {}.call(
However, if I change the code to:
sol::table nt = s.create_table();
sol::object o = sol::make_object(s, b2Vec2(1, 2));
nt["a"] = o;
Then it works.
I wonder why this happens and can it be fixed? Thanks!
Running into the same problem, and your solution helped!