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_);
80 t_ = make_small_shared_ptr<T>(*
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>
137 template <
typename Num>
165 "cannot increment the use count of a non-shareable reference");
173 "cannot decrement the use count of a non-shareable reference");
206 template <
typename Num>
208 (std::numeric_limits<Num>::max)();
218 template <
typename Num>
224 template <
typename Num>
230 template <
typename Num>
236 template <
typename Num,
typename T>
239 p.set_use_count(count);
242 template <
typename Num>
248 template <
typename Num>
A helper class to store use-counts of copy-on-write objects.
void increment_use_count()
copy_on_write_pointeet(const copy_on_write_pointeet &)
~copy_on_write_pointeet()=default
copy_on_write_pointeet & operator=(const copy_on_write_pointeet &)
void set_shareable(bool u)
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 & operator=(copy_on_write_pointeet &&)
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
copy_on_writet & operator=(copy_on_writet &&rhs)
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)
copy_on_writet & operator=(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
T & write(bool mark_shareable)
copy_on_writet(copy_on_writet &&rhs)
copy_on_writet(Ts &&... ts)
This class is really similar to boost's intrusive_pointer, but can be a bit simpler seeing as we're o...
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...