diff --git a/sol/stack.hpp b/sol/stack.hpp index be7907bd..5d4f67c5 100644 --- a/sol/stack.hpp +++ b/sol/stack.hpp @@ -84,6 +84,18 @@ inline void push_arithmetic(lua_State* L, T x, std::false_type) { // T is an floating point type lua_pushnumber(L, x); } + +template +inline void push_helper(lua_State* L, T& x, std::true_type) { + // T is a reference type + x.push(); +} + +template +inline void push_helper(lua_State* L, T& x, std::false_type) { + // T is a reference type + push_arithmetic(L, x, std::is_integral{}); +} } // detail template @@ -116,8 +128,8 @@ inline const char* pop(lua_State* L) { } template -inline void push(lua_State* L, T arithmetic) { - detail::push_arithmetic(L, arithmetic, std::is_integral{}); +inline void push(lua_State* L, T& t) { + detail::push_helper(L, t, std::is_base_of{}); } inline void push(lua_State* L, bool boolean) {