lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>> int gc_metamethod(lua_State* L)
>> {
>>  T* object = reinterpret_cast<T*>(lua_touserdata(L, 1));
>>  object->~T();
>>  return 0;
>> }
>
> It would be better to use static_cast.
> This is a essentially a matter of taste, but static_cast is for
> regular (mostly safe) casts, const_cast to work around when an API
> does not respect correct constness, dynamic_cast to try types at
> runtime, and reinterpret_cast is for "hacks". When I see it, it
> triggers this thought : "Hey, there is something tricky going on
> here".

This HAS to be a reinterpret_cast because all casts through void* are
considered unsafe by the compiler.

/s/ Adam