rmp::Handle
template <class T = Object>
class Handle
A reference to an object that is safe to keep across frames. It gives the object back while it is alive, and nothing from the moment destroy() is called on it, even once its slot holds another object. Object::handle() makes one; T is the type get() hands back.
get, operator bool, operator->, operator*
Ref<T> get() const
explicit operator bool() const
T *operator->() const
T &operator*() const
Empty until it points at something, and empty again the moment that something stops existing. A default-constructed handle has generation 0, which no live slot ever has.
-> and * on a handle whose object is gone are the empty Ref's: said once, and a stand-in instead of a crash. Ask first:
if (target) target->hp -= 1;Handle
Handle(unsigned index, unsigned generation)
Public so Object::handle() can build one without befriending every instantiation. Not for calling: the index and generation are ours.