From 6eac584c2ca3de073579e2f1683533de5eaa067f Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sun, 1 Jun 2014 01:07:26 -0400 Subject: [PATCH] Allow containers that use pairs as its value_type to return tables in lua as well --- sol/stack.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sol/stack.hpp b/sol/stack.hpp index d7029bc5..4ecc0ede 100644 --- a/sol/stack.hpp +++ b/sol/stack.hpp @@ -178,6 +178,16 @@ struct pusher { lua_settable(L, -3); } } + + template, has_key_value_pair> = 0> + static void push(lua_State* L, const T& cont) { + lua_createtable(L, cont.size(), 0); + for(auto&& pair : cont) { + pusher>::push(L, pair.first); + pusher>::push(L, pair.second); + lua_settable(L, -3); + } + } }; template<>