Class Reference::To

template<class Type, bool active = true>
class To

Shared pointer to Reference::Able object.

This smart pointer deletes a Reference::Able object when its reference count reaches zero, and is also invalidated when its target is destroyed.

For usage examples, see Reference::To smart pointer

Template Parameters:
  • Type – the child of Reference::Able to which this pointer can point. If Type is a base class, then this pointer can also point to derived types

  • active – When true, this smart pointer behaves like a std::shared_ptr; when false, this pointer is like a std::weak_ptr.

Public Functions

constexpr To() = default

Default constructor.

To(const To&)

Copy constructor.

~To()

Destructor.

To &operator=(const To&)

Assignment operator.

To(Type *ptr)

Construct from pointer.

To &operator=(Type*)

Assign from pointer.

inline Type &operator*() const

Object dereferencing operator.

inline Type *operator->() const

Member dereferencing operator.

bool operator==(const Type *ptr) const

Comparison operator.

bool operator!=(const Type *ptr) const

Comparison operator.

template<typename U = Type>
inline std::enable_if<!std::is_const<U>::value, bool>::type operator==(U *ptr) const

Comparison operator.

This overloaded operator is

  • prioritized over operator==(Type*, Type*) <built-in>

  • enabled only if Type is not const (e.g. Reference::To<const T>)

template<typename U = Type>
inline std::enable_if<!std::is_const<U>::value, bool>::type operator!=(U *ptr) const

Comparison operator.

This overloaded operator is

  • prioritized over operator!=(Type*, Type*) <built-in>

  • enabled only if Type is not const (e.g. Reference::To<const T>)

bool operator==(std::nullptr_t) const

Comparison operator.

This version is prioritized over operator!=(Type*, Type*) <built-in>

bool operator!=(std::nullptr_t) const

Comparison operator.

This version is prioritized over operator!=(Type*, Type*) <built-in>

bool is_equal_to(const Type *ptr) const

Worker method for all six comparison operator overloads.

inline operator Type*() const

Cast to Type* operator.

bool operator!() const

Returns true if reference is null.

operator bool() const

Returns true if reference is other than null.

void set(Type*)

Set the pointer.

Type *get() const

Return the pointer.

Type *release()

Return the pointer and unhook without deleting the object.

const Type *ptr() const

Return pointer without testing for validity.

Type *ptr()

Return pointer without testing for validity.

std::string name() const

Return the name of the object, as returned by typeid.