Преглед изворни кода

Add std::nullptr_t as equivalent to nil

Ole пре 10 година
родитељ
комит
96f6df49a3
1 измењених фајлова са 17 додато и 0 уклоњено
  1. 17 0
      lib/luwra/types.hpp

+ 17 - 0
lib/luwra/types.hpp

@@ -34,6 +34,23 @@ struct Value {
 	);
 };
 
+
+// Nil
+template <>
+struct Value<std::nullptr_t> {
+	static inline
+	std::nullptr_t read(State* state, int n) {
+		luaL_checktype(state, n, LUA_TNIL);
+		return nullptr;
+	}
+
+	static inline
+	int push(State* state, std::nullptr_t) {
+		lua_pushnil(state);
+		return 1;
+	}
+};
+
 /**
  * Convenient wrapped for `Value<T>::push`.
  */