sol2 icon indicating copy to clipboard operation
sol2 copied to clipboard

Cannot directly bind b2Vec2 to a table entry

Open linsyking opened this issue 1 year ago • 2 comments

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!

linsyking avatar Apr 12 '24 02:04 linsyking

Running into the same problem, and your solution helped!

andipeer avatar Jun 04 '24 05:06 andipeer