Go to the documentation of this file.
9 #ifndef CPROVER_UTIL_SMALL_SHARED_TWO_WAY_PTR_H
10 #define CPROVER_UTIL_SMALL_SHARED_TWO_WAY_PTR_H
12 #include <type_traits>
18 template <
typename Num>
33 template <
typename U,
typename V>
41 static_assert(std::is_base_of<
pointeet, U>::value, "");
42 static_assert(std::is_base_of<
pointeet, V>::value, "");
111 U *u = static_cast<U *>(
p);
116 V *v = static_cast<V *>(
p);
159 return static_cast<U *>(
p);
166 return static_cast<V *>(
p);
173 if(
p ==
nullptr || other.
p ==
nullptr)
179 explicit operator bool()
const
188 template <
typename U,
typename V,
typename... Ts>
194 template <
typename U,
typename V,
typename... Ts>
200 template <
typename U,
typename V>
205 return lhs.
get() == rhs.
get();
208 template <
typename U,
typename V>
213 return lhs.
get() != rhs.
get();
216 template <
typename Num>
220 static_assert(std::is_unsigned<Num>::value,
"");
222 static const int bit_idx = std::numeric_limits<Num>::digits - 1;
#define PRECONDITION(CONDITION)
decltype(std::declval< U >().use_count()) typedef use_countt
bool is_same_type(const small_shared_two_way_ptrt &other) const
Checks if the raw pointers held by *this and other both can be converted to either U* or V*.
bool operator==(const small_shared_two_way_ptrt< U, V > &lhs, const small_shared_two_way_ptrt< U, V > &rhs)
small_shared_two_way_pointeet & operator=(const small_shared_two_way_pointeet &)
bool is_derived_u() const
small_shared_two_way_pointeet()=default
void increment_use_count()
This class is similar to small_shared_ptrt and boost's intrusive_ptr.
small_shared_two_way_ptrt(const small_shared_two_way_ptrt &rhs)
bool is_derived_u() const
Checks if converting the held raw pointer to U* is valid.
small_shared_two_way_ptrt< U, V > make_shared_derived_v(Ts &&... ts)
bool is_same_type(const small_shared_two_way_pointeet &other) const
bool is_derived_v() const
Checks if converting the held raw pointer to V* is valid.
use_countt use_count() const
small_shared_two_way_ptrt & operator=(const small_shared_two_way_ptrt &rhs)
void swap(small_shared_two_way_ptrt &rhs)
bool is_derived_v() const
bool operator!=(const small_shared_two_way_ptrt< U, V > &lhs, const small_shared_two_way_ptrt< U, V > &rhs)
void decrement_use_count()
U * get_derived_u() const
small_shared_two_way_ptrt(small_shared_two_way_ptrt &&rhs)
V * get_derived_v() const
small_shared_two_way_ptrt & operator=(small_shared_two_way_ptrt &&rhs)
small_shared_two_way_ptrt< U, V > make_shared_derived_u(Ts &&... ts)
small_shared_two_way_pointeet(const small_shared_two_way_pointeet &)
small_shared_two_way_ptrt(V *v)
~small_shared_two_way_ptrt()