NPRPC docs

class ObjectPtr

C++

template <typename T> class ObjectPtr

Owning handle to a proxy (Object or a generated subclass), like a shared_ptr whose count lives in the object: copies call add_ref(), destruction and reset() call release().

Constructing from a raw pointer adopts a reference the caller already holds; it does not add one.

include/nprpc/object_ptr.hpp:17

Constructors

ObjectPtr<T>() noexcept

An empty handle.

include/nprpc/object_ptr.hpp:39

ObjectPtr<T>(const ObjectPtr<T> &other) noexcept

Shares other's object, adding a reference.

include/nprpc/object_ptr.hpp:45

explicit ObjectPtr<T>(T *obj) noexcept

Adopts obj and the reference the caller holds on it.

include/nprpc/object_ptr.hpp:52

ObjectPtr<T>(ObjectPtr<T> &&other) noexcept

Takes other's object, leaving other empty.

include/nprpc/object_ptr.hpp:58

Methods

void force_reset(T *obj = nullptr) noexcept

Deletes the current proxy without releasing it, e.g. after the runtime has shut down, and adopts obj.

include/nprpc/object_ptr.hpp:95

T *get() noexcept

The raw pointer, still owned by this handle.

include/nprpc/object_ptr.hpp:108

T *&get_address_of() noexcept

The stored pointer itself, for out-parameters that fill it in.

include/nprpc/object_ptr.hpp:110

void reset(T *obj = nullptr) noexcept

Releases the current object, if any, and adopts obj.

include/nprpc/object_ptr.hpp:87

Operators

operator bool() const noexcept

Whether the handle holds an object.

include/nprpc/object_ptr.hpp:105

T *operator->() noexcept

Calls a method on the object.

include/nprpc/object_ptr.hpp:103

ObjectPtr<T> &operator=(const ObjectPtr<T> &other) noexcept

Shares other's object, adding a reference, and releases the one held before.

include/nprpc/object_ptr.hpp:65

ObjectPtr<T> &operator=(ObjectPtr<T> &&other) noexcept

Takes other's object, leaving other empty, and releases the one held before.

include/nprpc/object_ptr.hpp:79