object ====== general-purpose safety reference to an existing object ------------------------------------------------------ .. code-block:: cpp class object : reference; ``object``'s goal is to allow someone to pass around the most generic form of a reference to something in Lua (or propogate a ``nil``). It is the logical extension of :doc:`sol::reference`, and is used in :ref:`sol::table's iterators`. members ------- .. code-block:: cpp :caption: constructor: coroutine coroutine(lua_State* L, int index = -1); Create an object which references the specific element at the given index in the specified ``lua_State*``. .. code-block:: cpp :caption: function: type conversion template decltype(auto) as() const; Performs a cast of the item this reference refers to into the type ``T`` and returns it. It obeys the same rules as :ref:`sol::stack::get\`. .. code-block:: cpp :caption: function: type check template bool is() const; Performs a type check using the :ref:`sol::stack::check` api, after checking if the reference is valid. non-members ----------- .. code-block:: cpp :caption: functions: nil comparators bool operator==(const object& lhs, const nil_t&); bool operator==(const nil_t&, const object& rhs); bool operator!=(const object& lhs, const nil_t&); bool operator!=(const nil_t&, const object& rhs); These allow a person to compare an ``sol::object`` against :ref:`nil`, which essentially checks if an object references a non-nil value, like so: .. code-block:: cpp if (myobj == sol::nil) { // doesn't have anything... } Use this to check objects. .. code-block:: cpp :caption: function: make object :name: make-object template object make_object(lua_State* L, T&& value); template object make_object(lua_State* L, Args&&... args); Makes an object out of the value. It pushes it onto the stack, then pops it into the returned ``sol::object``.