9#ifndef CPROVER_UTIL_COW_H
10#define CPROVER_UTIL_COW_H
29 template <
typename...
Ts>
35 "newly-constructed COW pointers must be shareable");
45 "newly-constructed COW pointers must be shareable");
68 std::swap(
t_, rhs.
t_);
84 "mutable references to a COW pointer must be unique");
103 template <
typename U>
109 template <
typename U>
115 template <
typename U>
121 template <
typename U>
137template <
typename Num>
165 "cannot increment the use count of a non-shareable reference");
173 "cannot decrement the use count of a non-shareable reference");
206template <
typename Num>
208 (std::numeric_limits<Num>::max)();
218template <
typename Num>
221 p.increment_use_count();
224template <
typename Num>
227 p.decrement_use_count();
230template <
typename Num>
233 return p.use_count();
236template <
typename Num,
typename T>
239 p.set_use_count(count);
242template <
typename Num>
248template <
typename Num>
251 return p.is_shareable();
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
A helper class to store use-counts of copy-on-write objects.
void increment_use_count()
copy_on_write_pointeet & operator=(copy_on_write_pointeet &&)
copy_on_write_pointeet(const copy_on_write_pointeet &)
~copy_on_write_pointeet()=default
void set_shareable(bool u)
copy_on_write_pointeet & operator=(const copy_on_write_pointeet &)
void decrement_use_count()
static const Num unshareable
A special sentry value which will be assigned to use_count_ if a mutable reference to the held object...
copy_on_write_pointeet()=default
bool is_shareable() const
copy_on_write_pointeet(copy_on_write_pointeet &&)
A utility class for writing types with copy-on-write behaviour (like irep).
bool operator>(const copy_on_writet< U > &rhs) const
T & write(bool mark_shareable)
bool operator>=(const copy_on_writet< U > &rhs) const
bool operator<=(const copy_on_writet< U > &rhs) const
bool operator!=(const copy_on_writet< U > &rhs) const
copy_on_writet(const copy_on_writet &rhs)
bool operator==(const copy_on_writet< U > &rhs) const
small_shared_ptrt< T > t_
void swap(copy_on_writet &rhs)
bool operator<(const copy_on_writet< U > &rhs) const
copy_on_writet & operator=(const copy_on_writet &rhs)
copy_on_writet(copy_on_writet &&rhs)
copy_on_writet & operator=(copy_on_writet &&rhs)
copy_on_writet(Ts &&... ts)
bool pointee_is_shareable(const copy_on_write_pointeet< Num > &p)
void pointee_increment_use_count(copy_on_write_pointeet< Num > &p)
The following functions are required by copy_on_writet, and by default pass through to the member fun...
void pointee_set_shareable(copy_on_write_pointeet< Num > &p, bool u)
void pointee_decrement_use_count(copy_on_write_pointeet< Num > &p)
Num pointee_use_count(const copy_on_write_pointeet< Num > &p)
void pointee_set_use_count(copy_on_write_pointeet< Num > &p, T count)
small_shared_ptrt< T > make_small_shared_ptr(Ts &&... ts)
This function is similar to std::make_unique and std::make_shared, and should be the preferred way of...
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.