cprover
|
A helper class to store use-counts of copy-on-write objects. More...
#include <cow.h>
Public Member Functions | |
copy_on_write_pointeet ()=default | |
copy_on_write_pointeet (const copy_on_write_pointeet &) | |
copy_on_write_pointeet & | operator= (const copy_on_write_pointeet &) |
copy_on_write_pointeet (copy_on_write_pointeet &&) | |
copy_on_write_pointeet & | operator= (copy_on_write_pointeet &&) |
void | increment_use_count () |
void | decrement_use_count () |
Num | use_count () const |
void | set_shareable (bool u) |
bool | is_shareable () const |
Protected Member Functions | |
~copy_on_write_pointeet ()=default | |
Private Attributes | |
Num | use_count_ = 0 |
Static Private Attributes | |
static const Num | unshareable |
A special sentry value which will be assigned to use_count_ if a mutable reference to the held object has been created. More... | |
A helper class to store use-counts of copy-on-write objects.
The suggested usage pattern is to have copy-on-write data types inherit from this class, and then to access them through a copy_on_writet.
Num | some numeric type, used to store a reference count |
|
default |
|
inline |
|
inline |
|
protecteddefault |
|
inline |
Definition at line 169 of file cow.h.
References INVARIANT, copy_on_write_pointeet< Num >::is_shareable(), and copy_on_write_pointeet< Num >::use_count_.
Referenced by pointee_decrement_use_count().
|
inline |
Definition at line 161 of file cow.h.
References INVARIANT, copy_on_write_pointeet< Num >::is_shareable(), and copy_on_write_pointeet< Num >::use_count_.
Referenced by pointee_increment_use_count().
|
inline |
Definition at line 187 of file cow.h.
References copy_on_write_pointeet< Num >::unshareable, and copy_on_write_pointeet< Num >::use_count_.
Referenced by copy_on_write_pointeet< Num >::decrement_use_count(), copy_on_write_pointeet< Num >::increment_use_count(), pointee_is_shareable(), and copy_on_write_pointeet< Num >::use_count().
|
inline |
|
inline |
|
inline |
Definition at line 182 of file cow.h.
References copy_on_write_pointeet< Num >::unshareable, and copy_on_write_pointeet< Num >::use_count_.
Referenced by pointee_set_shareable().
|
inline |
Definition at line 177 of file cow.h.
References copy_on_write_pointeet< Num >::is_shareable(), and copy_on_write_pointeet< Num >::use_count_.
Referenced by pointee_use_count().
|
staticprivate |
A special sentry value which will be assigned to use_count_ if a mutable reference to the held object has been created.
We check for this sentry value, and use it to decide whether the next copy constructor/assignment call should invoke a deep or shallow copy. Note that this is set to the max value that can be held by Num, but this cannot be done inline.
Definition at line 202 of file cow.h.
Referenced by copy_on_write_pointeet< Num >::is_shareable(), and copy_on_write_pointeet< Num >::set_shareable().
|
private |
Definition at line 203 of file cow.h.
Referenced by copy_on_write_pointeet< Num >::decrement_use_count(), copy_on_write_pointeet< Num >::increment_use_count(), copy_on_write_pointeet< Num >::is_shareable(), copy_on_write_pointeet< Num >::set_shareable(), and copy_on_write_pointeet< Num >::use_count().