cprover
|
This class is similar to small_shared_ptrt and boost's intrusive_ptr. More...
#include <small_shared_two_way_ptr.h>
Public Types | |
typedef small_shared_two_way_pointeet< use_countt > | pointeet |
Public Member Functions | |
small_shared_two_way_ptrt ()=default | |
small_shared_two_way_ptrt (U *u) | |
small_shared_two_way_ptrt (V *v) | |
small_shared_two_way_ptrt (const small_shared_two_way_ptrt &rhs) | |
small_shared_two_way_ptrt (small_shared_two_way_ptrt &&rhs) | |
small_shared_two_way_ptrt & | operator= (const small_shared_two_way_ptrt &rhs) |
small_shared_two_way_ptrt & | operator= (small_shared_two_way_ptrt &&rhs) |
~small_shared_two_way_ptrt () | |
void | swap (small_shared_two_way_ptrt &rhs) |
use_countt | use_count () const |
bool | is_derived_u () const |
Checks if converting the held raw pointer to U* is valid. More... | |
bool | is_derived_v () const |
Checks if converting the held raw pointer to V* is valid. More... | |
pointeet * | get () const |
U * | get_derived_u () const |
V * | get_derived_v () const |
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*. More... | |
operator bool () const | |
Public Attributes | |
decltype(std::declval< U >().use_count()) typedef | use_countt |
Private Attributes | |
pointeet * | p = nullptr |
This class is similar to small_shared_ptrt and boost's intrusive_ptr.
Like those, it stores the use count with the pointed-to object instead of in a separate control block. Additionally, it uses the MSB of the use count to indicate the type of the managed object (which is either of type U or V).
A possible use case is the implementation of data structures with sharing that consist of two different types of objects (such as a tree with internal nodes and leaf nodes). Storing the type with the use count avoids having to keep a separate type
member or using typeid
or dynamic_cast
. Moreover, since the shared pointer is aware of the concrete type of the object being stored, it can delete it without requiring a virtual destructor or custom delete function (like std::shared_ptr).
Definition at line 34 of file small_shared_two_way_ptr.h.
typedef small_shared_two_way_pointeet<use_countt> small_shared_two_way_ptrt< U, V >::pointeet |
Definition at line 39 of file small_shared_two_way_ptr.h.
|
default |
|
inlineexplicit |
Definition at line 46 of file small_shared_two_way_ptr.h.
|
inlineexplicit |
Definition at line 55 of file small_shared_two_way_ptr.h.
|
inline |
Definition at line 64 of file small_shared_two_way_ptr.h.
|
inline |
Definition at line 74 of file small_shared_two_way_ptr.h.
|
inline |
Definition at line 98 of file small_shared_two_way_ptr.h.
|
inline |
Definition at line 150 of file small_shared_two_way_ptr.h.
|
inline |
Definition at line 155 of file small_shared_two_way_ptr.h.
|
inline |
Definition at line 162 of file small_shared_two_way_ptr.h.
|
inline |
Checks if converting the held raw pointer to U*
is valid.
Definition at line 139 of file small_shared_two_way_ptr.h.
|
inline |
Checks if converting the held raw pointer to V*
is valid.
Definition at line 145 of file small_shared_two_way_ptr.h.
|
inline |
Checks if the raw pointers held by *this
and other
both can be converted to either U* or V*.
Definition at line 171 of file small_shared_two_way_ptr.h.
|
inlineexplicit |
Definition at line 179 of file small_shared_two_way_ptr.h.
|
inline |
Definition at line 81 of file small_shared_two_way_ptr.h.
|
inline |
Definition at line 90 of file small_shared_two_way_ptr.h.
|
inline |
Definition at line 126 of file small_shared_two_way_ptr.h.
|
inline |
Definition at line 133 of file small_shared_two_way_ptr.h.
|
private |
Definition at line 185 of file small_shared_two_way_ptr.h.
decltype(std::declval<U>().use_count()) typedef small_shared_two_way_ptrt< U, V >::use_countt |
Definition at line 37 of file small_shared_two_way_ptr.h.