mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Allow containers that use pairs as its value_type to return tables in lua as well
This commit is contained in:
parent
4cc402dc6e
commit
6eac584c2c
|
@ -178,6 +178,16 @@ struct pusher {
|
|||
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<>
|
||||
|
|
Loading…
Reference in New Issue
Block a user