diff --git a/sol/object.hpp b/sol/object.hpp index db374fd2..1c6f53d1 100644 --- a/sol/object.hpp +++ b/sol/object.hpp @@ -32,20 +32,36 @@ public: object() = default; template - T as() { + T as() const { push(); type_assert(state(), -1, type_of()); return stack::get(state()); } template - bool is() { + bool is() const { push(); auto expected = type_of(); auto actual = lua_type(state(), -1); return (static_cast(expected) == actual) || (expected == type::poly); } }; + +bool operator==(const object& lhs, const nil_t&) { + return lhs.is(); +} + +bool operator==(const nil_t&, const object& rhs) { + return rhs.is(); +} + +bool operator!=(const object& lhs, const nil_t&) { + return !lhs.is(); +} + +bool operator!=(const nil_t&, const object& rhs) { + return !rhs.is(); +} } // sol #endif // SOL_OBJECT_HPP \ No newline at end of file