Sfoglia il codice sorgente

Add std::nullptr_t as equivalent to nil

Ole 10 anni fa
parent
commit
96f6df49a3
1 ha cambiato i file con 17 aggiunte e 0 eliminazioni
  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`.
  */