|
Cogs.Core
|
A value that is cleared (zero-initialised) when it is moved from. More...
#include <UniqueValue.h>
Public Member Functions | |
| UniqueValue (const T &value) | |
| UniqueValue (const UniqueValue &)=delete | |
| UniqueValue (UniqueValue &&other) noexcept | |
| UniqueValue & | operator= (const UniqueValue &)=delete |
| UniqueValue & | operator= (UniqueValue &&other) noexcept |
Public Attributes | |
| T | value = T(0) |
A value that is cleared (zero-initialised) when it is moved from.
Use this to give a primitive member move-transfer semantics — the value travels to the new owner and is reset in the old one, preventing duplicate action on the same resource.
Example (from Cogs.Core Texture): a texture may wrap an externally-provided GPU handle that it does not always own. A plain bool ownsHandle would be copied on move, causing both the moved-from and moved-to object to believe they own the handle and attempt to release it. UniqueValue<bool> solves this by clearing the flag in the moved-from object automatically:
Definition at line 32 of file UniqueValue.h.
|
inline |
Definition at line 34 of file UniqueValue.h.
|
inlinenoexcept |
Definition at line 36 of file UniqueValue.h.
|
inlinenoexcept |
Definition at line 39 of file UniqueValue.h.
| T Cogs::UniqueValue< T >::value = T(0) |
Definition at line 41 of file UniqueValue.h.