|
CeresEngine 0.2.0
A game development framework
|
A pointer type that has value semantics. More...
#include <CeresEngine/Foundation/Poly.hpp>
Classes | |
| struct | ConstructTag |
| A tag used for tagged dispatching the object constructing constructor. More... | |
Public Member Functions | |
| bool | isCopyable () const noexcept |
Checks if the Poly copy constructor can be safely called. | |
| Poly (const Poly &other) | |
Creates a new Poly by copying an existing one. | |
| Poly & | operator= (const Poly &other) |
Assigns a Poly by copying an existing one. | |
| bool | isMovable () const noexcept |
Checks if the Poly move constructor can be safely called. | |
| Poly (Poly &&other) noexcept | |
Creates a new Poly by moving an existing one. | |
| Poly & | operator= (Poly &&other) |
Assigns a Poly by moving an existing one. | |
| Poly (std::nullptr_t) noexcept | |
Creates a new empty Poly. | |
| Poly & | operator= (std::nullptr_t) noexcept |
Assigns the Poly a nullptr value. | |
| ~Poly () noexcept | |
Destroys the Poly and destroys the object is present. | |
| template<typename TT = T> requires (std::is_default_constructible_v<TT>) | |
| Poly () noexcept | |
Creates a new empty Poly. | |
| template<typename TT , typename... Args> requires (std::is_convertible_v<TT*, T*>&& std::is_constructible_v<TT, Args&&...>) | |
| Poly (std::in_place_type_t< TT >, Args &&... args) | |
Creates a new Poly that holds a newly constructed object of type TT. | |
| template<typename... Args> requires (std::is_constructible_v<T, Args...>) | |
| Poly (Args &&... args) | |
Creates a new Poly that holds a newly constructed object of type T. | |
| template<typename TT > requires (std::is_convertible_v<TT*, T*> && Copyable) | |
| Poly (TT object) | |
Creates a new Poly that holds a copy constructed object of type TT. | |
| template<typename TT > requires (std::is_convertible_v<TT*, T*> && !Copyable) | |
| Poly (TT &&object) | |
Creates a new Poly that holds a copy constructed object of type TT. | |
| Poly (T *const instance) | |
Creates a new Poly instance by referencing another. | |
| template<typename TT , typename... Args> requires std::is_constructible_v<TT, Args...> | |
| TT & | emplace (Args &&... args) |
Emplace a new object of type TT into the Poly. | |
| template<typename TT > | |
| TT & | emplace (TT &&instance) |
| template<typename U > requires (Copyable) | |
| Poly (const Poly< U, SmallSize, Copyable, BaseType > &other) | |
Creates a new Poly instance by referencing another. | |
| template<typename U > | |
| Poly (Poly< U, SmallSize, Copyable, BaseType > &&other) | |
Creates a new Poly instance by referencing another. | |
| 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. | |
| operator bool () const | |
| Checks if the pointer has a valid object stored in it. | |
| T * | get () |
| const T * | get () const |
| T * | operator-> () |
| const T * | operator-> () const |
| const T & | operator* () const & |
| T & | operator* () & |
| & | |
| T && | operator* () && |
| & | |
| const std::type_info & | getTypeID () const |
| template<typename TT > requires std::is_convertible_v<TT*, T*> | |
| bool | is () const |
Checks if the hold object is of type TT. | |
| template<typename TT > requires std::is_convertible_v<TT*, T*> | |
| TT * | being () |
Safely casts the hold type to TT. | |
| template<typename TT > requires std::is_convertible_v<TT*, T*> | |
| const TT * | being () const |
Safely casts the hold type to TT. | |
| template<typename TT > requires std::is_convertible_v<TT*, T*> | |
| TT & | as () & |
Casts the hold type to TT. | |
| template<typename TT > requires std::is_convertible_v<TT*, T*> | |
| TT && | as () && |
Casts the hold type to TT. | |
| template<typename TT > requires std::is_convertible_v<TT*, T*> | |
| const TT & | as () const & |
Casts the hold type to TT. | |
Static Public Attributes | |
| template<typename U > | |
| static constexpr bool | isSmall = sizeof(U) <= SmallSize&& std::is_move_constructible_v<U> |
true if an object of type U will not cause an allocation. | |
Private Types | |
| using | Implementation = impl::PolyImplementation< BaseType > |
Private Member Functions | |
| template<typename TT , typename... Args> requires (std::is_convertible_v<TT*, T*>&& std::is_constructible_v<TT, Args&&...>) | |
| Poly (ConstructTag< TT >, Args &&... args) | |
Creates a new Poly that holds a newly constructed object of type TT. | |
| void | reset () |
| Resets the stored object into an empty state. | |
Static Private Member Functions | |
| template<typename TT > | |
| static const Implementation * | create () |
Creates a new implementation for the concrete type TT. | |
| static const Implementation * | getReference () |
| Gets the implementation table for referencing the polymorphic object as a reference. | |
Private Attributes | |
| Byte | mRaw [SmallSize] |
| The underlying storage memory. | |
| const Implementation * | mImplementation = nullptr |
| A Implementation that contains implementation for copy, move and destroy. | |
Friends | |
| template<typename , size_t , bool , typename > | |
| class | Poly |
A pointer type that has value semantics.
When creating a new Poly, an object of type T or that has T as a base is created. When copying Poly objects, the object is copied by calling its copy constructor.
When a Poly 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. |
| Copyable | If true, indicates that the Poly object is copyable. |
|
private |
|
inline |
Creates a new Poly by copying an existing one.
| other | The instance to copy from |
|
inlinenoexcept |
Creates a new Poly by moving an existing one.
| other | The instance to move from |
|
inlinenoexcept |
Creates a new empty Poly.
|
inlinenoexcept |
Destroys the Poly and destroys the object is present.
|
inlineexplicitprivate |
Creates a new Poly 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 Poly.
|
inlineexplicit |
Creates a new Poly that holds a newly constructed object of type TT.
| TT | the object type |
| Args | the object constructor argument types |
| args | The object constructor arguments |
|
inlineexplicit |
Creates a new Poly that holds a newly constructed object of type T.
| Args | the object constructor argument types |
| args | The object constructor arguments |
|
inline |
Creates a new Poly that holds a copy constructed object of type TT.
| TT | the object type |
|
inline |
Creates a new Poly that holds a copy constructed object of type TT.
| TT | the object type |
|
inline |
Casts the hold type to TT.
If the type is invalid, the behavior is undefined.
| TT | the type to cast to |
|
inline |
Casts the hold type to TT.
If the type is invalid, the behavior is undefined.
| TT | the type to cast to |
|
inline |
Casts the hold type to TT.
If the type is invalid, the behavior is undefined.
| TT | the type to cast to |
|
inline |
Safely casts the hold type to TT.
If the type is invalid, nullptr is returned.
| TT | the type to cast to |
nullptr if TT is not the hold type.
|
inline |
Safely casts the hold type to TT.
If the type is invalid, nullptr is returned.
| TT | the type to cast to |
nullptr if TT is not the hold type.
|
inlinestaticprivate |
Creates a new implementation for the concrete type TT.
|
inline |
Emplace a new object of type TT into the Poly.
| TT | the object type |
| Args | the object constructor argument types |
| args | The object constructor arguments |
|
inline |
|
inline |
Checks if the pointer has a valid object stored in it.
true if the stored object is valid
|
inline |
|
inline |
|
inlinestaticprivate |
Gets the implementation table for referencing the polymorphic object as a reference.
|
inline |
std::type_info of the hold object type
|
inline |
Checks if the hold object is of type TT.
This can be costly.
| TT | the type to check for |
true if the hold type is TT.
|
inlinenoexcept |
Checks if the Poly copy constructor can be safely called.
|
inlinenoexcept |
Checks if the Poly 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 |
|
inline |
|
inline |
|
inlinenoexcept |
Assigns the Poly a nullptr value.
*this
|
inlineprivate |
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
|
friend |
|
inlinestaticconstexpr |
true if an object of type U will not cause an allocation.
|
private |
A Implementation that contains implementation for copy, move and destroy.
|
mutableprivate |
The underlying storage memory.