I am new to Lua and C++-Lua binding and currently I have weird problem. This works:
- I can pass
std::vectorof custom, complex, type and get the size of it in Lua - I can access any element of above
std::vectorin Lua and execute a method on it
also:
- I can pass
std::vectorof POD type (likeint) and get the size of it in Lua (size ofstd::vector)
However I am unable to get given int from the vector, entire app crashes when trying to do.
The irony is, all bindings for std::vector is made via the same helper function(2 example functions here):
template < typename T_ >
void BindVectorOf( luabind::class_< std::vector< T_ > > & vectorClass )
{
typedef std::vector< T_ > Vector;
typedef Vector::reference ( Vector::* AtMethod )( Vector::size_type );
vectorClass
.def( luabind::constructor< >( ) )
.def( "Size", &Vector::size )
.def( "At", (AtMethod)&Vector::at )
);
}
So in short above Size method works always, but At method works only on complex (custom) types, it does not work for int for example.
Does Lua have something against POD types? :-) What I am missing?
Just to be on the safe side, I tried to bind and then force int32_t to make int 32-bit, no difference, on first access to std::vector element I have crash.
