خرید بک لینک

Vote count: 0

I am new to Lua and C++-Lua binding and currently I have weird problem. This works:

  • I can pass std::vector of custom, complex, type and get the size of it in Lua
  • I can access any element of above std::vector in Lua and execute a method on it

also:

  • I can pass std::vector of POD type (like int) and get the size of it in Lua (size of std::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.

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 30 فروردين 1395 ساعت: 16:50

صفحه بندی