CBMC
copy_on_writet< T > Class Template Referencefinal

A utility class for writing types with copy-on-write behaviour (like irep). More...

#include <cow.h>

Public Member Functions

template<typename... Ts>
 copy_on_writet (Ts &&... ts)
 
 copy_on_writet (const copy_on_writet &rhs)
 
copy_on_writetoperator= (const copy_on_writet &rhs)
 
 copy_on_writet (copy_on_writet &&rhs)
 
copy_on_writetoperator= (copy_on_writet &&rhs)
 
void swap (copy_on_writet &rhs)
 
const T & read () const
 
T & write (bool mark_shareable)
 
template<typename U >
bool operator== (const copy_on_writet< U > &rhs) const
 
template<typename U >
bool operator!= (const copy_on_writet< U > &rhs) const
 
template<typename U >
bool operator< (const copy_on_writet< U > &rhs) const
 
template<typename U >
bool operator> (const copy_on_writet< U > &rhs) const
 
template<typename U >
bool operator<= (const copy_on_writet< U > &rhs) const
 
template<typename U >
bool operator>= (const copy_on_writet< U > &rhs) const
 

Private Attributes

small_shared_ptrt< T > t_
 

Detailed Description

template<typename T>
class copy_on_writet< T >

A utility class for writing types with copy-on-write behaviour (like irep).

This is a thin wrapper over a shared pointer, but instead of a single getter for the pointer value, we supply a separate 'read' and 'write' method. 'read' returns a reference to the owned object, while 'write' will create a copy of the owned object if more than one copy_on_write instance points to it.

Definition at line 24 of file cow.h.

Constructor & Destructor Documentation

◆ copy_on_writet() [1/3]

template<typename T >
template<typename... Ts>
copy_on_writet< T >::copy_on_writet ( Ts &&...  ts)
inlineexplicit

Definition at line 30 of file cow.h.

◆ copy_on_writet() [2/3]

template<typename T >
copy_on_writet< T >::copy_on_writet ( const copy_on_writet< T > &  rhs)
inline

Definition at line 38 of file cow.h.

◆ copy_on_writet() [3/3]

template<typename T >
copy_on_writet< T >::copy_on_writet ( copy_on_writet< T > &&  rhs)
inline

Definition at line 55 of file cow.h.

Member Function Documentation

◆ operator!=()

template<typename T >
template<typename U >
bool copy_on_writet< T >::operator!= ( const copy_on_writet< U > &  rhs) const
inline

Definition at line 98 of file cow.h.

◆ operator<()

template<typename T >
template<typename U >
bool copy_on_writet< T >::operator< ( const copy_on_writet< U > &  rhs) const
inline

Definition at line 104 of file cow.h.

◆ operator<=()

template<typename T >
template<typename U >
bool copy_on_writet< T >::operator<= ( const copy_on_writet< U > &  rhs) const
inline

Definition at line 116 of file cow.h.

◆ operator=() [1/2]

template<typename T >
copy_on_writet& copy_on_writet< T >::operator= ( const copy_on_writet< T > &  rhs)
inline

Definition at line 48 of file cow.h.

◆ operator=() [2/2]

template<typename T >
copy_on_writet& copy_on_writet< T >::operator= ( copy_on_writet< T > &&  rhs)
inline

Definition at line 60 of file cow.h.

◆ operator==()

template<typename T >
template<typename U >
bool copy_on_writet< T >::operator== ( const copy_on_writet< U > &  rhs) const
inline

Definition at line 92 of file cow.h.

◆ operator>()

template<typename T >
template<typename U >
bool copy_on_writet< T >::operator> ( const copy_on_writet< U > &  rhs) const
inline

Definition at line 110 of file cow.h.

◆ operator>=()

template<typename T >
template<typename U >
bool copy_on_writet< T >::operator>= ( const copy_on_writet< U > &  rhs) const
inline

Definition at line 122 of file cow.h.

◆ read()

template<typename T >
const T& copy_on_writet< T >::read ( ) const
inline

Definition at line 71 of file cow.h.

◆ swap()

template<typename T >
void copy_on_writet< T >::swap ( copy_on_writet< T > &  rhs)
inline

Definition at line 66 of file cow.h.

◆ write()

template<typename T >
T& copy_on_writet< T >::write ( bool  mark_shareable)
inline

Definition at line 76 of file cow.h.

Member Data Documentation

◆ t_

template<typename T >
small_shared_ptrt<T> copy_on_writet< T >::t_
private

Definition at line 128 of file cow.h.


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