ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
irep_container< T > Class Template Reference

Reference counted container for irep2 nodes. More...

#include <irep2.h>

Public Member Functions

constexpr irep_container () noexcept
 irep_container (const irep_container &ref) noexcept
 irep_container (irep_container &&ref) noexcept
 ~irep_container ()
irep_container & operator= (const irep_container &ref) noexcept
irep_container & operator= (irep_container &&ref) noexcept
const T & operator* () const noexcept
const T * operator-> () const noexcept
const T * get () const noexcept
T * get ()
T & operator* ()
T * operator-> ()
 operator bool () const noexcept
void reset () noexcept
void detach ()
void swap (irep_container &b) noexcept
irep_container simplify () const
size_t crc () const

Friends

template<class U, class... Args>
irep_container< typename U::base_type > make_irep (Args &&... args)
 Allocate a fresh irep2 node and adopt it into an irep_container.
void swap (irep_container &a, irep_container &b) noexcept
bool operator== (const irep_container &a, const irep_container &b)
bool operator!= (const irep_container &a, const irep_container &b)
bool operator< (const irep_container &a, const irep_container &b)
bool operator<= (const irep_container &a, const irep_container &b)
bool operator>= (const irep_container &a, const irep_container &b)
bool operator> (const irep_container &a, const irep_container &b)

Detailed Description

template<class T>
class irep_container< T >

Reference counted container for irep2 nodes.

Holds a raw T * to an irep2-derived node and manages its intrusive refcount: construction increments, destruction decrements, the pointee is deleted when the count reaches zero. Single allocation per node — no separate control block, no shared_ptr indirection.

The container also implements the historic copy-on-write contract: the only way to obtain a non-const T * / T & is via the non-const get() / operator* / operator->, all of which call detach() first. If the underlying node is shared (refcount > 1), detach() allocates a fresh copy via T::clone() and rebinds the container to that copy; the other holders keep observing the original. This preserves the value semantics of the legacy string-irep irept while letting most subtree copies be cheap.

Threading. See irep2.h's preamble. The refcount is atomic (acq/rel on release/destruction, relaxed on construction copy) but the container is not designed for concurrent mutation: under the single-writer contract there is at most one mutator at a time, while readers may share the same node.

Constructor & Destructor Documentation

◆ irep_container() [1/3]

template<class T>
irep_container< T >::irep_container ( )
inlineconstexprnoexcept

◆ irep_container() [2/3]

template<class T>
irep_container< T >::irep_container ( const irep_container< T > & ref)
inlinenoexcept

◆ irep_container() [3/3]

template<class T>
irep_container< T >::irep_container ( irep_container< T > && ref)
inlinenoexcept

◆ ~irep_container()

template<class T>
irep_container< T >::~irep_container ( )
inline

Member Function Documentation

◆ crc()

template<class T>
size_t irep_container< T >::crc ( ) const
inline

◆ detach()

template<class T>
void irep_container< T >::detach ( )
inline

◆ get() [1/2]

template<class T>
T * irep_container< T >::get ( )
inline

◆ get() [2/2]

template<class T>
const T * irep_container< T >::get ( ) const
inlinenodiscardnoexcept

◆ operator bool()

template<class T>
irep_container< T >::operator bool ( ) const
inlineexplicitnoexcept

◆ operator*() [1/2]

template<class T>
T & irep_container< T >::operator* ( )
inline

◆ operator*() [2/2]

template<class T>
const T & irep_container< T >::operator* ( ) const
inlinenodiscardnoexcept

◆ operator->() [1/2]

template<class T>
T * irep_container< T >::operator-> ( )
inline

◆ operator->() [2/2]

template<class T>
const T * irep_container< T >::operator-> ( ) const
inlinenodiscardnoexcept

◆ operator=() [1/2]

template<class T>
irep_container & irep_container< T >::operator= ( const irep_container< T > & ref)
inlinenoexcept

◆ operator=() [2/2]

template<class T>
irep_container & irep_container< T >::operator= ( irep_container< T > && ref)
inlinenoexcept

◆ reset()

template<class T>
void irep_container< T >::reset ( )
inlinenoexcept

◆ simplify()

template<class T>
irep_container irep_container< T >::simplify ( ) const
inline

◆ swap()

template<class T>
void irep_container< T >::swap ( irep_container< T > & b)
inlinenoexcept

◆ make_irep

template<class T>
template<class U, class... Args>
irep_container< typename U::base_type > make_irep ( Args &&... args)
friend

Allocate a fresh irep2 node and adopt it into an irep_container.

The single canonical construction path for the intrusive refcount scheme. T must derive from an irep2 base (type2t / expr2t) that exposes base_type as its method-side base; the returned container is irep_container<T::base_type> (i.e. type2tc or expr2tc).

Single allocation, no separate control block, exception-safe (if any argument constructor throws, the new hasn't run yet; if the new itself throws, no leak; the only ordering between new succeeding and the container adopting it is straight-line code inside this function).

Callers should prefer this helper over a raw new-into-container so the allocation site stays in one place.

◆ operator!=

template<class T>
bool operator!= ( const irep_container< T > & a,
const irep_container< T > & b )
friend

◆ operator<

template<class T>
bool operator< ( const irep_container< T > & a,
const irep_container< T > & b )
friend

◆ operator<=

template<class T>
bool operator<= ( const irep_container< T > & a,
const irep_container< T > & b )
friend

◆ operator==

template<class T>
bool operator== ( const irep_container< T > & a,
const irep_container< T > & b )
friend

◆ operator>

template<class T>
bool operator> ( const irep_container< T > & a,
const irep_container< T > & b )
friend

◆ operator>=

template<class T>
bool operator>= ( const irep_container< T > & a,
const irep_container< T > & b )
friend

◆ swap

template<class T>
void swap ( irep_container< T > & a,
irep_container< T > & b )
friend

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