CBMC
copy_on_write_pointeet< Num > Class Template Reference

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_pointeetoperator= (const copy_on_write_pointeet &)
 
 copy_on_write_pointeet (copy_on_write_pointeet &&)
 
copy_on_write_pointeetoperator= (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...
 

Detailed Description

template<typename Num>
class copy_on_write_pointeet< Num >

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.

Template Parameters
Numsome numeric type, used to store a reference count

Definition at line 138 of file cow.h.

Constructor & Destructor Documentation

◆ copy_on_write_pointeet() [1/3]

template<typename Num >
copy_on_write_pointeet< Num >::copy_on_write_pointeet ( )
default

◆ copy_on_write_pointeet() [2/3]

template<typename Num >
copy_on_write_pointeet< Num >::copy_on_write_pointeet ( const copy_on_write_pointeet< Num > &  )
inline

Definition at line 143 of file cow.h.

◆ copy_on_write_pointeet() [3/3]

template<typename Num >
copy_on_write_pointeet< Num >::copy_on_write_pointeet ( copy_on_write_pointeet< Num > &&  )
inline

Definition at line 152 of file cow.h.

◆ ~copy_on_write_pointeet()

template<typename Num >
copy_on_write_pointeet< Num >::~copy_on_write_pointeet ( )
protecteddefault

Member Function Documentation

◆ decrement_use_count()

template<typename Num >
void copy_on_write_pointeet< Num >::decrement_use_count ( )
inline

Definition at line 169 of file cow.h.

◆ increment_use_count()

template<typename Num >
void copy_on_write_pointeet< Num >::increment_use_count ( )
inline

Definition at line 161 of file cow.h.

◆ is_shareable()

template<typename Num >
bool copy_on_write_pointeet< Num >::is_shareable ( ) const
inline

Definition at line 187 of file cow.h.

◆ operator=() [1/2]

template<typename Num >
copy_on_write_pointeet& copy_on_write_pointeet< Num >::operator= ( const copy_on_write_pointeet< Num > &  )
inline

Definition at line 147 of file cow.h.

◆ operator=() [2/2]

template<typename Num >
copy_on_write_pointeet& copy_on_write_pointeet< Num >::operator= ( copy_on_write_pointeet< Num > &&  )
inline

Definition at line 156 of file cow.h.

◆ set_shareable()

template<typename Num >
void copy_on_write_pointeet< Num >::set_shareable ( bool  u)
inline

Definition at line 182 of file cow.h.

◆ use_count()

template<typename Num >
Num copy_on_write_pointeet< Num >::use_count ( ) const
inline

Definition at line 177 of file cow.h.

Member Data Documentation

◆ unshareable

template<typename Num >
const Num copy_on_write_pointeet< Num >::unshareable
staticprivate
Initial value:
=
(std::numeric_limits<Num>::max)()

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.

◆ use_count_

template<typename Num >
Num copy_on_write_pointeet< Num >::use_count_ = 0
private

Definition at line 203 of file cow.h.


The documentation for this class was generated from the following file: