diff --git a/include/GarrysMod/Lua/LuaBase.h b/include/GarrysMod/Lua/LuaBase.h index 0ceab47e..92c6c10d 100644 --- a/include/GarrysMod/Lua/LuaBase.h +++ b/include/GarrysMod/Lua/LuaBase.h @@ -278,7 +278,7 @@ namespace GarrysMod // Creates a new UserData with your own data embedded within it template - void PushUserType_Value( const T& val, int iType ) + void PushUserType_Value( const T& val, int iType, bool has_gc = false ) { using UserData_T = UserData_Value; @@ -286,10 +286,13 @@ namespace GarrysMod static_assert( std::alignment_of::value <= 8, "PushUserType_Value given type with unsupported alignment requirement" ); - // Don't give this function objects that can't be trivially destructed - // You could ignore this limitation if you implement object destruction in `__gc` - static_assert( std::is_trivially_destructible::value, - "PushUserType_Value given type that is not trivially destructible" ); + + if ( !has_gc ) { + // Don't give this function objects that can't be trivially destructed + // You could ignore this limitation if you implement object destruction in `__gc` + static_assert(std::is_trivially_destructible::value, + "PushUserType_Value given type that is not trivially destructible"); + } auto* ud = static_cast( NewUserdata( sizeof( UserData_T ) ) ); ud->data = new( &ud->value ) T ( val );