stlab::copy_on_write 1.0.3
Copy-on-write wrapper for any type
|
#include <stlab/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.
Definition at line 101 of file copy_on_write.hpp.
using stlab::copy_on_write< T >::element_type = T |
The type of value stored.
Definition at line 137 of file copy_on_write.hpp.
using stlab::copy_on_write< T >::value_type = T |
Definition at line 132 of file copy_on_write.hpp.
|
inlinenoexcept |
Default constructs the wrapped value.
Definition at line 142 of file copy_on_write.hpp.
|
inline |
Constructs a new instance by forwarding arguments to the wrapped value constructor.
Definition at line 153 of file copy_on_write.hpp.
|
inline |
Constructs a new instance by forwarding multiple arguments to the wrapped value constructor.
Definition at line 159 of file copy_on_write.hpp.
|
inlinenoexcept |
Copy constructor that shares the underlying data with the source object.
Definition at line 165 of file copy_on_write.hpp.
|
inlinenoexcept |
Move constructor that takes ownership of the source object's data.
Definition at line 175 of file copy_on_write.hpp.
|
inline |
Definition at line 179 of file copy_on_write.hpp.
|
inlinenodiscardnoexcept |
Returns true if this object and the given object share the same underlying data.
Definition at line 305 of file copy_on_write.hpp.
|
inlinenoexcept |
Implicit conversion to const reference of the underlying value.
Definition at line 273 of file copy_on_write.hpp.
|
inlinenoexcept |
Dereference operator that returns a const reference to the underlying value.
Definition at line 278 of file copy_on_write.hpp.
|
inlinenoexcept |
Arrow operator that returns a const pointer to the underlying value.
Definition at line 283 of file copy_on_write.hpp.
|
inlinenoexcept |
Copy assignment operator that shares the underlying data with the source object.
Definition at line 193 of file copy_on_write.hpp.
|
inlinenoexcept |
Move assignment operator that takes ownership of the source object's data.
Definition at line 202 of file copy_on_write.hpp.
|
inline |
Assigns a new value to the wrapped object, optimizing for in-place assignment when unique.
Definition at line 212 of file copy_on_write.hpp.
|
inlinenodiscardnoexcept |
Returns a const reference to the underlying value for read-only access.
Definition at line 264 of file copy_on_write.hpp.
|
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.
Definition at line 290 of file copy_on_write.hpp.
|
inlinenodiscardnoexcept |
Definition at line 300 of file copy_on_write.hpp.
|
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.
Definition at line 227 of file copy_on_write.hpp.
|
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. |
Definition at line 246 of file copy_on_write.hpp.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
Definition at line 382 of file copy_on_write.hpp.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
Definition at line 386 of file copy_on_write.hpp.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
Definition at line 390 of file copy_on_write.hpp.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
Definition at line 322 of file copy_on_write.hpp.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
Definition at line 326 of file copy_on_write.hpp.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
Definition at line 330 of file copy_on_write.hpp.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
Definition at line 346 of file copy_on_write.hpp.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
Definition at line 350 of file copy_on_write.hpp.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
Definition at line 354 of file copy_on_write.hpp.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
Definition at line 370 of file copy_on_write.hpp.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
Definition at line 374 of file copy_on_write.hpp.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
Definition at line 378 of file copy_on_write.hpp.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
Definition at line 334 of file copy_on_write.hpp.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
Definition at line 338 of file copy_on_write.hpp.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
Definition at line 342 of file copy_on_write.hpp.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
Definition at line 358 of file copy_on_write.hpp.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
Definition at line 362 of file copy_on_write.hpp.
|
friend |
Comparisons can be done with the underlying value or the copy_on_write object.
Definition at line 366 of file copy_on_write.hpp.
|
friend |
Efficiently swaps the contents of two copy_on_write objects.
Definition at line 314 of file copy_on_write.hpp.