From f2d72f7bb23c2c2d0e9b9d8b924e574907e5fd52 Mon Sep 17 00:00:00 2001 From: HFCPC Date: Mon, 25 Nov 2013 16:44:05 -0500 Subject: [PATCH] Allow push to work with types that inherit from reference --- sol/stack.hpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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) {