xentara-utils v1.2.1
Xentara utilities library
Loading...
Searching...
No Matches
xentara::utils::memory::IndirectObject< Object > Class Template Reference

An object allocated indirectly on the heap. More...

#include <memory/IndirectObject.hpp>

Public Member Functions

template<typename... Arguments>
requires std::is_constructible_v<Object, Arguments &&...> && tools::kNotCopyMove<IndirectObject<Object>, Arguments...>
 IndirectObject (Arguments &&... arguments) noexcept(std::is_nothrow_constructible_v< Object, Arguments &&... >)
 In-place constructor.
 
 IndirectObject (const IndirectObject &other) noexcept(std::is_nothrow_copy_constructible_v< Object >)
 Copy constructor.
 
 IndirectObject (IndirectObject &&other) noexcept
 Move constructor.
 
auto operator= (const IndirectObject &rhs) noexcept(std::is_nothrow_copy_assignable_v< IndirectObject > &&std::is_nothrow_copy_constructible_v< IndirectObject >) -> IndirectObject &
 Assignment operator.
 
auto operator= (IndirectObject &&rhs) noexcept -> IndirectObject &
 Move assignment operator.
 
auto operator* () const -> const Object &
 Gets the object.
 
auto operator* () -> Object &
 Gets the object.
 
auto operator-> () const -> const Object *
 Accesses a member of the object.
 
auto operator-> () -> Object *
 Accesses a member of the object.
 
auto operator== (const IndirectObject &rhs) noexcept -> bool
 Comparison operator.
 
auto operator<=> (const IndirectObject &rhs) noexcept -> std::compare_three_way_result< Object, Object >
 Three-way comparison operator.
 
template<std::equality_comparable_with< Object > Other>
requires (!std::same_as<Other, IndirectObject>)
auto operator== (const Other &rhs) noexcept -> bool
 Comparison operator with another type.
 
template<std::three_way_comparable_with< Object > Other>
requires (!std::same_as<Other, IndirectObject>)
auto operator<=> (const IndirectObject &rhs) noexcept -> std::compare_three_way_result< Object, Other >
 Three-way comparison operator with another type.
 
template<typename... Arguments>
requires std::is_constructible_v<Object, Arguments &&...>
auto emplace (Arguments &&... arguments) noexcept(std::is_nothrow_constructible_v< Object, Arguments &&... >) -> void
 creates a new object with the given arguments
 

Detailed Description

template<typename Object>
class xentara::utils::memory::IndirectObject< Object >

An object allocated indirectly on the heap.

Constructor & Destructor Documentation

◆ IndirectObject() [1/3]

template<typename Object >
template<typename... Arguments>
requires std::is_constructible_v<Object, Arguments &&...> && tools::kNotCopyMove<IndirectObject<Object>, Arguments...>
xentara::utils::memory::IndirectObject< Object >::IndirectObject ( Arguments &&...  arguments)
noexcept

In-place constructor.

Constructs an object with the given arguments

◆ IndirectObject() [2/3]

template<typename Object >
xentara::utils::memory::IndirectObject< Object >::IndirectObject ( const IndirectObject< Object > &  other)
noexcept

Copy constructor.

Copies the object.

◆ IndirectObject() [3/3]

template<typename Object >
xentara::utils::memory::IndirectObject< Object >::IndirectObject ( IndirectObject< Object > &&  other)
noexcept

Move constructor.

Transfers the object and leaves the source unusable.

Member Function Documentation

◆ emplace()

template<typename Object >
template<typename... Arguments>
requires std::is_constructible_v<Object, Arguments &&...>
auto xentara::utils::memory::IndirectObject< Object >::emplace ( Arguments &&...  arguments) -> void
noexcept

creates a new object with the given arguments

◆ operator*() [1/2]

template<typename Object >
auto xentara::utils::memory::IndirectObject< Object >::operator* ( ) -> Object &

Gets the object.

Attention
This function must not be called on objects that have been moved away using the move constructor or move assigment operator.
Returns
A reference to the object

◆ operator*() [2/2]

template<typename Object >
auto xentara::utils::memory::IndirectObject< Object >::operator* ( ) const -> const Object &

Gets the object.

Attention
This function must not be called on objects that have been moved away using the move constructor or move assigment operator.
Returns
A reference to the object

◆ operator->() [1/2]

template<typename Object >
auto xentara::utils::memory::IndirectObject< Object >::operator-> ( ) -> Object *

Accesses a member of the object.

Returns
Returns a pointer to the object, or nullptr if the object has has been moved away using the move constructor or move assigment operator.

◆ operator->() [2/2]

template<typename Object >
auto xentara::utils::memory::IndirectObject< Object >::operator-> ( ) const -> const Object *

Accesses a member of the object.

Returns
Returns a pointer to the object, or nullptr if the object has been moved away using the move constructor or move assigment operator.

◆ operator<=>() [1/2]

template<typename Object >
auto xentara::utils::memory::IndirectObject< Object >::operator<=> ( const IndirectObject< Object > &  rhs) -> std::compare_three_way_result<Object, Object>
noexcept

Three-way comparison operator.

This operator compares the objects. Objects that have been moved away using the move constructor or move assignment operator only compare equal to themselves, and compare less than valid objects. When comparing two invalid objects, an arbitrary but consistent ordering will be returned.

◆ operator<=>() [2/2]

template<typename Object >
template<std::three_way_comparable_with< Object > Other>
requires (!std::same_as<Other, IndirectObject>)
auto xentara::utils::memory::IndirectObject< Object >::operator<=> ( const IndirectObject< Object > &  rhs) -> std::compare_three_way_result<Object, Other>
noexcept

Three-way comparison operator with another type.

This operator compares the object with another object. Objects that have been moved away using the move constructor or move assignment operator always compare less.

◆ operator=() [1/2]

template<typename Object >
auto xentara::utils::memory::IndirectObject< Object >::operator= ( const IndirectObject< Object > &  rhs) -> IndirectObject &
noexcept

Assignment operator.

Assigns the object. If the object has been moved away using the move constructor or move assignment operator, a new copy is created.

◆ operator=() [2/2]

template<typename Object >
auto xentara::utils::memory::IndirectObject< Object >::operator= ( IndirectObject< Object > &&  rhs) -> IndirectObject &
noexcept

Move assignment operator.

Transfers the object and leaves the source unusable. Any old object is destroyed.

◆ operator==() [1/2]

template<typename Object >
auto xentara::utils::memory::IndirectObject< Object >::operator== ( const IndirectObject< Object > &  rhs) -> bool
noexcept

Comparison operator.

This operator compares the objects. Objects that have been moved away using the move constructor or move assignment operator only compare equal to themselves.

◆ operator==() [2/2]

template<typename Object >
template<std::equality_comparable_with< Object > Other>
requires (!std::same_as<Other, IndirectObject>)
auto xentara::utils::memory::IndirectObject< Object >::operator== ( const Other &  rhs) -> bool
noexcept

Comparison operator with another type.

This operator compares the object with another object. Objects that have been moved away using the move constructor or move assignment operator always compare unequal.