2016-03-12 06:47:15 +08:00
object
======
general-purpose safety reference to an existing object
------------------------------------------------------
.. code-block :: cpp
class object : reference;
2016-03-13 20:30:14 +08:00
`` 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<reference>` , and is used in :ref: `sol::table's iterators<table-iterators>` .
2016-03-12 06:47:15 +08:00
members
-------
2016-04-09 12:55:12 +08:00
.. 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* `` .
2016-03-12 06:47:15 +08:00
.. code-block :: cpp
:caption: function: type conversion
template<typename T>
decltype(auto) as() const;
2016-03-14 14:34:02 +08:00
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\<T><getter>` .
2016-03-12 06:47:15 +08:00
.. code-block :: cpp
:caption: function: type check
template<typename T>
bool is() const;
2016-03-13 20:30:14 +08:00
Performs a type check using the :ref: `sol::stack::check<checker>` api, after checking if the reference is valid.
2016-03-12 06:47:15 +08:00
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);
2016-03-13 20:30:14 +08:00
These allow a person to compare an `` sol::object `` against :ref: `nil<nil>` , which essentially checks if an object references a non-nil value, like so: