浏览代码

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`.
  */