copy_on_write Class Template Reference |
Public Types | |
typedef T | value_type |
Public Member Functions | |
copy_on_write (move_from< copy_on_write > x) | |
copy_on_write (const copy_on_write &x) | |
template<typename U> | |
copy_on_write (const U &x, typename copy_sink< U, T >::type=0) | |
template<typename U> | |
copy_on_write (U x, typename move_sink< U, T >::type=0) | |
copy_on_write () | |
bool | identity (const copy_on_write &x) const |
operator const value_type & () const | |
const value_type & | operator* () const |
const value_type * | operator-> () const |
template<typename U> | |
copy_sink< U, T, copy_on_write & > ::type | operator= (const U &x) |
template<typename U> | |
move_sink< U, T, copy_on_write & > ::type | operator= (U x) |
copy_on_write & | operator= (copy_on_write x) |
const value_type & | read () const |
bool | unique_instance () const |
value_type & | write () |
~copy_on_write () | |
Friends | |
bool | operator< (const copy_on_write &x, const copy_on_write &y) |
bool | operator== (const copy_on_write &x, const copy_on_write &y) |
void | swap (copy_on_write &x, copy_on_write &y) |
Member Typedef Documentation
typedef T value_type |
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 70 of file copy_on_write.hpp.
copy_on_write | ( | U | x, | |
typename move_sink< U, T >::type | = 0 | |||
) | [explicit] |
Constructs a new copy_on_write object with a value x
.
- Parameters:
-
\c 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 86 of file copy_on_write.hpp.
copy_on_write | ( | const U & | x, | |
typename copy_sink< U, T >::type | = 0 | |||
) | [explicit] |
Constructs a new copy_on_write object with a value x
.
- Parameters:
-
\c x A default value to assign to this object
- Note:
- This constructor is for value types which do support the move library.
Definition at line 99 of file copy_on_write.hpp.
copy_on_write | ( | const copy_on_write< T > & | x | ) |
Copy construction is a non-throwing operation and simply increments the reference count on the stored object.
Definition at line 108 of file copy_on_write.hpp.
copy_on_write | ( | move_from< copy_on_write< T > > | x | ) |
Definition at line 114 of file copy_on_write.hpp.
~copy_on_write | ( | ) |
Definition at line 120 of file copy_on_write.hpp.
Member Function Documentation
bool identity | ( | const copy_on_write< T > & | 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 265 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 206 of file copy_on_write.hpp.
const value_type& operator* | ( | ) | const |
Obtain a const reference to the underlying object.
- Returns:
- A const reference to the underlying object
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 pointer to the underlying object
Definition at line 228 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 245 of file copy_on_write.hpp.
copy_sink<U, T, copy_on_write&>::type operator= | ( | const U & | x | ) |
Definition at line 153 of file copy_on_write.hpp.
move_sink<U, T, copy_on_write&>::type operator= | ( | U | x | ) |
Assign a value which is convertible to value_type directly to a copy_on_write object.
Definition at line 138 of file copy_on_write.hpp.
copy_on_write& operator= | ( | copy_on_write< T > | x | ) |
As with copy construction, assignment is a non-throwing operation which releases the old value and incriments the reference count of the item being assigned to.
Definition at line 130 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 194 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 258 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.
- 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 > & | x, | |
const copy_on_write< T > & | y | |||
) | [friend] |
Definition at line 270 of file copy_on_write.hpp.
bool operator== | ( | const copy_on_write< T > & | x, | |
const copy_on_write< T > & | y | |||
) | [friend] |
Definition at line 273 of file copy_on_write.hpp.
void swap | ( | copy_on_write< T > & | x, | |
copy_on_write< T > & | y | |||
) | [friend] |
Definition at line 267 of file copy_on_write.hpp.