|
CeresEngine 0.2.0
A game development framework
|
A copy-on-write pointer type that shares a single instance of an object when copied but allows. More...
#include <CeresEngine/Foundation/SmartPtr.hpp>
Classes | |
| struct | Data |
Public Member Functions | |
| CopyOnWritePtr ()=default | |
| Create a new empty copy-on-write pointer. | |
| template<typename U > requires (std::is_constructible_v<T, U>) | |
| CopyOnWritePtr (U &&value) | |
Creates a new copy-on-write pointer by constructing a new object of type U. | |
| CopyOnWritePtr (std::nullptr_t) noexcept | |
| Create a new empty copy-on-write pointer. | |
| CopyOnWritePtr (const CopyOnWritePtr &) noexcept=default | |
| Creates a copy of the CoW pointer. | |
| CopyOnWritePtr & | operator= (const CopyOnWritePtr &) noexcept=default |
| Assigns a copy of the CoW pointer. | |
| CopyOnWritePtr (CopyOnWritePtr &&) noexcept=default | |
| Creates a copy of the CoW pointer. | |
| CopyOnWritePtr & | operator= (CopyOnWritePtr &&) noexcept=default |
| Assigns a copy of the CoW pointer. | |
| bool | valid () const noexcept |
| Checks if the pointer points to a valid object. | |
| operator bool () const noexcept | |
| Checks if the pointer points to a valid object. | |
| const T * | get () const noexcept |
| Gets a const pointer to the object. | |
| const T & | operator* () const noexcept |
| Gets a const pointer to the object. | |
| const T * | operator-> () const noexcept |
| Gets a const pointer to the object. | |
| void | reset () |
| Resets the stored pointer and empties the CoW pointer. | |
| template<typename Func > | |
| decltype(auto) | mutate (Func &&func) |
| Changes the pointer. | |
Private Member Functions | |
| template<typename U , typename... Args> | |
| CopyOnWritePtr (std::in_place_type_t< U >, Args &&... args) | |
Creates a new copy-on-write pointer by constructing a new object of type U. | |
| void | makeCopyIfNeeded () |
| Checks if we are the only user of the CoW pointer. | |
Private Attributes | |
| Data | mData |
| A pointer to the object shared by all instances of the copy-on-write object. | |
Friends | |
| bool | operator== (const CopyOnWritePtr &lhs, const CopyOnWritePtr &rhs) noexcept |
| Checks if the two pointers point to the same copy of the object. | |
| bool | operator!= (const CopyOnWritePtr &lhs, const CopyOnWritePtr &rhs) noexcept |
| Checks if the two pointers do not point to the same copy of the object. | |
| bool | operator== (const CopyOnWritePtr &lhs, std::nullptr_t) noexcept |
| Checks if the two pointers point to the same copy of the object. | |
| bool | operator!= (const CopyOnWritePtr &lhs, std::nullptr_t) noexcept |
| Checks if the two pointers do not point to the same copy of the object. | |
| bool | operator== (std::nullptr_t, const CopyOnWritePtr &rhs) noexcept |
| Checks if the two pointers point to the same copy of the object. | |
| bool | operator!= (std::nullptr_t, const CopyOnWritePtr &rhs) noexcept |
| Checks if the two pointers do not point to the same copy of the object. | |
| template<typename T1 , typename U , typename... Args> | |
| CopyOnWritePtr< T1 > | ce_cow_new (Args &&... args) |
Creates a new copy-on-write pointer by constructing a new object of type U. | |
A copy-on-write pointer type that shares a single instance of an object when copied but allows.
| T |
|
default |
Create a new empty copy-on-write pointer.
|
inline |
Creates a new copy-on-write pointer by constructing a new object of type U.
| value | The object to be copied to the CoW pointer. |
|
inlinenoexcept |
Create a new empty copy-on-write pointer.
|
defaultnoexcept |
Creates a copy of the CoW pointer.
This won't copy the data, but will copy a reference to the original pointer.
|
defaultnoexcept |
Creates a copy of the CoW pointer.
This won't copy the data, but will copy a reference to the original pointer.
|
inlineexplicitprivate |
Creates a new copy-on-write pointer by constructing a new object of type U.
| Args | The object constructor argument types. |
| args | The object constructor arguments. |
Gets a const pointer to the object.
|
inlineprivate |
Checks if we are the only user of the CoW pointer.
If not, make a copy of the contents.
|
inline |
Changes the pointer.
Makes a copy of it if required.
| Func | The function to be called to make changes to the stored object. |
| func | The function to be called to make changes to the stored object. |
func functor, if any.
|
inlineexplicitnoexcept |
Checks if the pointer points to a valid object.
|
inlinenoexcept |
Gets a const pointer to the object.
|
inlinenoexcept |
Gets a const pointer to the object.
|
defaultnoexcept |
Assigns a copy of the CoW pointer.
This won't copy the data, but will copy a reference to the original pointer.
|
defaultnoexcept |
Assigns a copy of the CoW pointer.
This won't copy the data, but will copy a reference to the original pointer.
|
inline |
Resets the stored pointer and empties the CoW pointer.
|
inlinenoexcept |
Checks if the pointer points to a valid object.
|
friend |
Creates a new copy-on-write pointer by constructing a new object of type U.
| U | The type of object to created a new instance for. |
| Args | The constructor argument types for the type U. |
| args | The constructor arguments for the type U. |
|
friend |
Checks if the two pointers do not point to the same copy of the object.
Checks if the two pointers do not point to the same copy of the object.
Checks if the two pointers do not point to the same copy of the object.
|
friend |
Checks if the two pointers point to the same copy of the object.
Checks if the two pointers point to the same copy of the object.
Checks if the two pointers point to the same copy of the object.
|
private |
A pointer to the object shared by all instances of the copy-on-write object.