stlab-copy-on-write 1.0.4
Copy-on-write wrapper for any type
|
#include <copy_on_write.hpp>
Public Types | |
using | value_type = T |
using | element_type = T |
Public Member Functions | |
copy_on_write () noexcept(std::is_nothrow_constructible_v< T >) | |
template<class U> | |
copy_on_write (U &&x, disable_copy< U >=nullptr) | |
template<class U, class V, class... Args> | |
copy_on_write (U &&x, V &&y, Args &&... args) | |
copy_on_write (const copy_on_write &x) noexcept | |
copy_on_write (copy_on_write &&x) noexcept | |
auto | operator= (const copy_on_write &x) noexcept -> copy_on_write & |
auto | operator= (copy_on_write &&x) noexcept -> copy_on_write & |
template<class U> | |
auto | operator= (U &&x) -> disable_copy_assign< U > |
auto | write () -> element_type & |
template<class Transform, class Inplace> | |
auto | write (Transform transform, Inplace inplace) -> element_type & |
auto | read () const noexcept -> const element_type & |
operator const element_type & () const noexcept | |
auto | operator* () const noexcept -> const element_type & |
auto | operator-> () const noexcept -> const element_type * |
auto | unique () const noexcept -> bool |
auto | unique_instance () const noexcept -> bool |
auto | identity (const copy_on_write &x) const noexcept -> bool |
Friends | |
void | swap (copy_on_write &x, copy_on_write &y) noexcept |
auto | operator< (const copy_on_write &x, const copy_on_write &y) noexcept -> bool |
auto | operator< (const copy_on_write &x, const element_type &y) noexcept -> bool |
auto | operator< (const element_type &x, const copy_on_write &y) noexcept -> bool |
auto | operator> (const copy_on_write &x, const copy_on_write &y) noexcept -> bool |
auto | operator> (const copy_on_write &x, const element_type &y) noexcept -> bool |
auto | operator> (const element_type &x, const copy_on_write &y) noexcept -> bool |
auto | operator<= (const copy_on_write &x, const copy_on_write &y) noexcept -> bool |
auto | operator<= (const copy_on_write &x, const element_type &y) noexcept -> bool |
auto | operator<= (const element_type &x, const copy_on_write &y) noexcept -> bool |
auto | operator>= (const copy_on_write &x, const copy_on_write &y) noexcept -> bool |
auto | operator>= (const copy_on_write &x, const element_type &y) noexcept -> bool |
auto | operator>= (const element_type &x, const copy_on_write &y) noexcept -> bool |
auto | operator== (const copy_on_write &x, const copy_on_write &y) noexcept -> bool |
auto | operator== (const copy_on_write &x, const element_type &y) noexcept -> bool |
auto | operator== (const element_type &x, const copy_on_write &y) noexcept -> bool |
auto | operator!= (const copy_on_write &x, const copy_on_write &y) noexcept -> bool |
auto | operator!= (const copy_on_write &x, const element_type &y) noexcept -> bool |
auto | operator!= (const element_type &x, const copy_on_write &y) noexcept -> bool |
A copy-on-write wrapper for any type that models Regular.
Copy-on-write semantics allow for an object to be lazily copied - only creating a copy when the value is modified and there is more than one reference to the value.
This class is thread safe and supports types that model Moveable.
using stlab::copy_on_write< T >::element_type = T |
The type of value stored.
using stlab::copy_on_write< T >::value_type = T |
|
inlinenoexcept |
Default constructs the wrapped value.
|
inline |
Constructs a new instance by forwarding arguments to the wrapped value constructor.
|
inline |
Constructs a new instance by forwarding multiple arguments to the wrapped value constructor.
|
inlinenoexcept |
Copy constructor that shares the underlying data with the source object.
|
inlinenoexcept |
Move constructor that takes ownership of the source object's data.
|
inlinenodiscardnoexcept |
Returns true if this object and the given object share the same underlying data.
|
inlinenoexcept |
Implicit conversion to const reference of the underlying value.
|
inlinenoexcept |
Dereference operator that returns a const reference to the underlying value.
|
inlinenoexcept |
Arrow operator that returns a const pointer to the underlying value.
|
inlinenoexcept |
Copy assignment operator that shares the underlying data with the source object.
|
inlinenoexcept |
Move assignment operator that takes ownership of the source object's data.
|
inline |
Assigns a new value to the wrapped object, optimizing for in-place assignment when unique.
|
inlinenodiscardnoexcept |
Returns a const reference to the underlying value for read-only access.
|
inlinenodiscardnoexcept |
Returns true if this is the only reference to the underlying object.
This is useful to determine if calling write() will cause a copy.
|
inlinenodiscardnoexcept |
|
inline |
Obtains a non-const reference to the underlying value.
This will copy the underlying value if necessary so changes to the value do not affect other copy_on_write objects sharing the same data.
|
inline |
If the object is not unique, the transform is applied to the underlying value to copy it and a reference to the new value is returned. If the object is unique, the inplace function is called with a reference to the underlying value and a reference to the value is returned.
transform | A function object that takes a const reference to the underlying value and returns a new value. |
inplace | A function object that takes a reference to the underlying value and modifies it in place. |
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
|
friend |
Efficiently swaps the contents of two copy_on_write objects.