copy_on_write< T, A > Class Template Reference |
typedef A allocator_type |
The type of allocator.
Definition at line 77 of file copy_on_write.hpp.
typedef T value_type |
The type of value stored.
Definition at line 75 of file copy_on_write.hpp.
Constructor & Destructor Documentation
copy_on_write | ( | ) |
The first call to the default constructor will construct a default instance of value_type which will be used for subsequent calls to the default constructor. The default instance will be released at exit.
Definition at line 91 of file copy_on_write.hpp.
copy_on_write | ( | const allocator_type & | a ) | [explicit] |
Initializes the instance with a custom allocator
Definition at line 101 of file copy_on_write.hpp.
copy_on_write | ( | T | x ) |
Constructs a new copy_on_write object with a value x
.
- Parameters:
-
x A default value to assign to this object
- Note:
- This constructor is for value types which do not support the move library.
Definition at line 116 of file copy_on_write.hpp.
copy_on_write | ( | const copy_on_write< T, A > & | x ) |
Copy construction is a non-throwing operation and simply increments the reference count on the stored object.
Definition at line 124 of file copy_on_write.hpp.
copy_on_write | ( | move_from< copy_on_write< T, A > > | x ) |
Definition at line 131 of file copy_on_write.hpp.
~copy_on_write | ( | ) |
Definition at line 137 of file copy_on_write.hpp.
Member Function Documentation
allocator_type get_allocator | ( | ) | const |
Definition at line 271 of file copy_on_write.hpp.
bool identity | ( | const copy_on_write< T, A > & | x ) | const |
identity is used to see if two copy_on_write items refer to the same instance.
- Returns:
- Boolean;
true
if the underlying object instance is shared by both objects.
Definition at line 247 of file copy_on_write.hpp.
operator const value_type & | ( | ) | const |
Obtain a const reference to the underlying object.
- Returns:
- A const reference to the underlying object
Definition at line 201 of file copy_on_write.hpp.
const value_type& operator* | ( | ) | const |
Obtain a const reference to the underlying object.
This is provided because you cannot override operator.()
. It allows copy_on_write to be used with common transformation techniques, such as boost indirect_iterator
and transform_iterator
. It does not imply "pointer" semantics.
- Returns:
- A const reference to the underlying object
Definition at line 214 of file copy_on_write.hpp.
const value_type* operator-> | ( | ) | const |
Obtain a const pointer to the underlying object.
This is provided because you cannot override operator.()
. It allows copy_on_write to be used with common transformation techniques, such as boost indirect_iterator
and transform_iterator
. It does not imply "pointer" semantics.
- Returns:
- A const pointer to the underlying object
Definition at line 227 of file copy_on_write.hpp.
copy_on_write& operator= | ( | copy_on_write< T, A > | x ) |
As with copy construction, assignment is a non-throwing operation which releases the old value and increments the reference count of the item being assigned to.
Definition at line 147 of file copy_on_write.hpp.
copy_on_write& operator= | ( | T | x ) |
Definition at line 151 of file copy_on_write.hpp.
const value_type& read | ( | ) | const |
Obtain a const reference to the underlying object.
- Returns:
- A const reference to the underlying object
Definition at line 190 of file copy_on_write.hpp.
bool unique_instance | ( | ) | const |
unique_instance returns whether or not the reference count to the object instance is one. This is useful to determine if writing will cause a copy.
- Returns:
true
if the ref count for the instance is one.
Definition at line 237 of file copy_on_write.hpp.
value_type& write | ( | ) |
Obtain a reference to the value the object is referencing. This will copy the underlying value (if necessary) so changes to the value do not affect other copy_on_write objects.
Note that write() does not have the same preconditions as operator=(). write() returns a reference to the underlying object's value, thus requiring that an underlying object exist. operator=() on the other hand will perform an allocation if one is necessary.
- Returns:
- A reference to the underlying object
Definition at line 175 of file copy_on_write.hpp.
Friends And Related Function Documentation
bool operator!= | ( | const copy_on_write< T, A > & | x, |
const copy_on_write< T, A > & | y | ||
) | [friend] |
Definition at line 268 of file copy_on_write.hpp.
bool operator< | ( | const copy_on_write< T, A > & | x, |
const copy_on_write< T, A > & | y | ||
) | [friend] |
Definition at line 253 of file copy_on_write.hpp.
bool operator<= | ( | const copy_on_write< T, A > & | x, |
const copy_on_write< T, A > & | y | ||
) | [friend] |
Definition at line 259 of file copy_on_write.hpp.
bool operator== | ( | const copy_on_write< T, A > & | x, |
const copy_on_write< T, A > & | y | ||
) | [friend] |
Definition at line 265 of file copy_on_write.hpp.
bool operator> | ( | const copy_on_write< T, A > & | x, |
const copy_on_write< T, A > & | y | ||
) | [friend] |
Definition at line 256 of file copy_on_write.hpp.
bool operator>= | ( | const copy_on_write< T, A > & | x, |
const copy_on_write< T, A > & | y | ||
) | [friend] |
Definition at line 262 of file copy_on_write.hpp.
void swap | ( | copy_on_write< T, A > & | x, |
copy_on_write< T, A > & | y | ||
) | [friend] |
Definition at line 250 of file copy_on_write.hpp.