|
CeresEngine 0.2.0
A game development framework
|
A pointer type that has value semantics. More...
#include <CeresEngine/Foundation/SmartPtr.hpp>
Classes | |
| struct | ConstructTag |
| A tag used for tagged dispatching the object constructing constructor. More... | |
| struct | VTable |
Public Member Functions | |
| bool | isCopyable () const noexcept |
Checks if the ValuePtr copy constructor can be safely called. | |
| ValuePtr (const ValuePtr &other) | |
Creates a new ValuePtr by copying an existing one. | |
| ValuePtr & | operator= (const ValuePtr &other) |
Assigns a ValuePtr by copying an existing one. | |
| bool | isMovable () const noexcept |
Checks if the ValuePtr move constructor can be safely called. | |
| ValuePtr (ValuePtr &&other) noexcept | |
Creates a new ValuePtr by moving an existing one. | |
| ValuePtr & | operator= (ValuePtr &&other) |
Assigns a ValuePtr by moving an existing one. | |
| ValuePtr (std::nullptr_t) noexcept | |
Creates a new empty ValuePtr. | |
| ValuePtr & | operator= (std::nullptr_t) noexcept |
Assigns the ValuePtr a nullptr value. | |
| ~ValuePtr () noexcept | |
Destroys the ValuePtr and destroys the object is present. | |
| template<bool B = std::is_default_constructible_v<T>&& std::is_copy_constructible_v<T>, typename = std::enable_if_t<B>> | |
| ValuePtr () noexcept | |
Creates a new empty ValuePtr. | |
| template<typename... Args, typename = std::enable_if_t<std::is_constructible_v<T, Args...>>> | |
| ValuePtr (Args &&... args) | |
Creates a new ValuePtr that holds a newly constructed object of type T. | |
| template<typename TT > requires (std::is_convertible_v<TT*, T*>) | |
| ValuePtr (TT object) | |
Creates a new ValuePtr that holds a copy constructed object of type TT. | |
| template<typename TT , typename... Args, typename = std::enable_if_t<std::is_constructible_v<TT, Args...>>> | |
| TT & | emplace (Args &&... args) |
Emplace a new object of type TT into the ValuePtr. | |
| bool | valid () const |
| Checks if the pointer has a valid object stored in it. | |
| bool | empty () const |
| Checks if the pointer has a valid object stored in it. | |
| T * | get () const |
| void | reset () |
| Resets the stored object into an empty state. | |
| operator bool () const | |
| Checks if the pointer has a valid object stored in it. | |
| T * | operator-> () const |
| T & | operator* () const |
Static Public Member Functions | |
| template<typename... Args> | |
| static ValuePtr< T, SmallSize > | create (Args &&... args) |
Create a new ValuePtr with an object of type T | |
| template<typename U , typename... Args> | |
| static ValuePtr< T, SmallSize > | create (Args &&... args) |
Create a new ValuePtr with an object of type U | |
Static Public Attributes | |
| template<typename U > | |
| static constexpr bool | isSmall = sizeof(U) <= SmallSize |
true if an object of type U will cause an allocation. | |
Private Member Functions | |
| template<typename TT , typename... Args, typename = std::enable_if_t<std::is_convertible_v<TT*, T*> && std::is_constructible_v<TT, Args...>>> | |
| ValuePtr (ConstructTag< TT >, Args &&... args) | |
Creates a new ValuePtr that holds a newly constructed object of type TT. | |
Private Attributes | |
| const VTable * | vtable = nullptr |
| A VTable that contains implementation for copy, move and destroy. | |
| UInt8 | raw [SmallSize] |
| The underlying storage memory. | |
A pointer type that has value semantics.
When creating a new ValuePtr, an object of type T or that has T as a base is created. When copying ValuePtr objects, the object is copied by calling its copy constructor.
When a ValuePtr is destroyed any object that might be contained in it is also destroyed.
| T | the object type |
| SmallSize | if the concrete object is up to this size, it will be allocated on internal storage and no heap allocation will take place. By default, limits to the size of 4 ints. |
Creates a new ValuePtr by copying an existing one.
| other | The instance to copy from |
Creates a new ValuePtr by moving an existing one.
| other | The instance to move from |
|
inlinenoexcept |
Creates a new empty ValuePtr.
|
inlinenoexcept |
Destroys the ValuePtr and destroys the object is present.
|
inlineexplicitprivate |
Creates a new ValuePtr that holds a newly constructed object of type TT.
| TT | the object type |
| Args | the object constructor argument types |
| args | The object constructor arguments |
|
inlinenoexcept |
Creates a new empty ValuePtr.
|
inlineexplicit |
Creates a new ValuePtr that holds a newly constructed object of type T.
| Args | the object constructor argument types |
| args | The object constructor arguments |
|
inline |
Creates a new ValuePtr that holds a copy constructed object of type TT.
| TT | the object type |
|
inline |
Emplace a new object of type TT into the ValuePtr.
| TT | the object type |
| Args | the object constructor argument types |
| args | The object constructor arguments |
|
inline |
Checks if the pointer has a valid object stored in it.
true if the stored object is not valid
|
inline |
|
inlinenoexcept |
Checks if the ValuePtr copy constructor can be safely called.
|
inlinenoexcept |
Checks if the ValuePtr move constructor can be safely called.
|
inlineexplicit |
Checks if the pointer has a valid object stored in it.
true if the stored object is valid
|
inline |
|
inline |
|
inline |
Assigns a ValuePtr by copying an existing one.
| other | The instance to copy from |
*this
|
inlinenoexcept |
Assigns the ValuePtr a nullptr value.
*this
|
inline |
Assigns a ValuePtr by moving an existing one.
| other | The instance to move from |
*this
|
inline |
Resets the stored object into an empty state.
If an object is present, it will be deconstructed.
|
inline |
Checks if the pointer has a valid object stored in it.
true if the stored object is valid
|
inlinestaticconstexpr |
true if an object of type U will cause an allocation.
|
mutableprivate |
The underlying storage memory.
A VTable that contains implementation for copy, move and destroy.