Allow containers that use pairs as its value_type to return tables in lua as well

This commit is contained in:
Rapptz 2014-06-01 01:07:26 -04:00
parent 4cc402dc6e
commit 6eac584c2c

View File

@ -178,6 +178,16 @@ struct pusher {
lua_settable(L, -3); lua_settable(L, -3);
} }
} }
template<typename U = T, EnableIf<has_begin_end<U>, has_key_value_pair<U>> = 0>
static void push(lua_State* L, const T& cont) {
lua_createtable(L, cont.size(), 0);
for(auto&& pair : cont) {
pusher<Unqualified<decltype(pair.first)>>::push(L, pair.first);
pusher<Unqualified<decltype(pair.second)>>::push(L, pair.second);
lua_settable(L, -3);
}
}
}; };
template<> template<>