![]() |
Thoth
A functional, expressive, asynchronous C++26 webdev library
|
Like Rust's cow (copy on write).
More...
#include <Cow.hpp>
Public Types | |
| using | ValueType = std::variant< RefT, OwnT > |
| using | RefType = RefT |
| using | OwnType = OwnT |
Public Member Functions | |
| constexpr | Cow ()=default |
| constexpr | Cow (RefT) noexcept |
| constexpr | Cow (Cow &&) noexcept=default |
| constexpr | Cow (const Cow &other) |
| constexpr Cow & | operator= (Cow &&other) noexcept=default |
| constexpr Cow & | operator= (const Cow &other) |
| constexpr Cow & | SetRef (RefT ref) |
| Sets the value to a new RefT. | |
| constexpr bool | IsRef () const |
| Check if the value is a RefT or OwnT. | |
| constexpr Cow & | SetOwned (const OwnT &own) |
| Set value to a new OwnT from another OwnT. | |
| constexpr Cow & | SetOwned (OwnT &&own) |
| Set value to a new OwnT from another OwnT. | |
| constexpr OwnT & | AsOwned () |
| Converts the RefT type to a OwnT. | |
| constexpr OwnT | AsCopy () const |
| Returns a copy of the value as OwnT without modifying it. | |
| constexpr RefT | AsRef () const |
| Returns a reference of the value as RefT without modifying it. | |
| template<class Callable > | |
| constexpr decltype(auto) | Visit (Callable &&callable) |
| convenient call to std::visit() on _value. | |
| template<class Callable > | |
| constexpr decltype(auto) | Visit (Callable &&callable) const |
| convenient call to std::visit() on _value. | |
Static Public Member Functions | |
| static constexpr Cow | FromRef (RefT ref) |
| Constructs a Cow from a RefT. | |
| static constexpr bool | IsRefType (const Cow &cow) |
| Check if the value is a RefT or OwnT. | |
| static constexpr Cow | FromOwned (const OwnT &own) |
| Create a OwnT value from another OwnT. | |
| static constexpr Cow | FromOwned (OwnT &&own) |
| Create a OwnT value from another OwnT. | |
Like Rust's cow (copy on write).
The value can a RefT or a OwnT. RefT are lightweight objects designed to reference external buffers, while OwnT are objects that stores it own data so they can be heavy to create and copy. Editing the Cow triggers transform the RefT in OwnT. You need to be able to construct OwnT from RefT and RefT from OwnT.
| using Thoth::Dsa::Cow< RefT, OwnT >::OwnType = OwnT |
| using Thoth::Dsa::Cow< RefT, OwnT >::RefType = RefT |
| using Thoth::Dsa::Cow< RefT, OwnT >::ValueType = std::variant<RefT, OwnT> |
|
constexprdefault |
|
constexprnoexcept |
|
constexprdefaultnoexcept |
|
constexpr |
|
constexpr |
Returns a copy of the value as OwnT without modifying it.
|
constexpr |
Converts the RefT type to a OwnT.
|
constexpr |
Returns a reference of the value as RefT without modifying it.
|
staticconstexpr |
Create a OwnT value from another OwnT.
|
staticconstexpr |
Create a OwnT value from another OwnT.
|
staticconstexpr |
Constructs a Cow from a RefT.
|
constexpr |
Check if the value is a RefT or OwnT.
|
staticconstexpr |
Check if the value is a RefT or OwnT.
|
constexpr |
|
constexprdefaultnoexcept |
|
constexpr |
Set value to a new OwnT from another OwnT.
|
constexpr |
Set value to a new OwnT from another OwnT.
|
constexpr |
Sets the value to a new RefT.
|
constexpr |
convenient call to std::visit() on _value.
|
constexpr |
convenient call to std::visit() on _value.