Kaynağa Gözat

Make Table constructors be able to create tables for you

Ole 9 yıl önce
ebeveyn
işleme
3b834d734b
1 değiştirilmiş dosya ile 8 ekleme ve 0 silme
  1. 8 0
      lib/luwra/tables.hpp

+ 8 - 0
lib/luwra/tables.hpp

@@ -133,6 +133,14 @@ struct Table {
 		luaL_checktype(state, index, LUA_TTABLE);
 	}
 
+	Table(State* state):
+		Table(state, (lua_newtable(state), -1))
+	{}
+
+	Table(State* state, const MemberMap& fields):
+		Table(state, (luwra::push(state, fields), -1))
+	{}
+
 	template <typename K> inline
 	internal::TableAccessor<internal::Path<const Reference&, K>> access(K&& key) const {
 		return {ref.impl->state, {ref, std::forward<K>(key)}};