Home | History | Annotate | Download | only in memory

Lines Matching defs:linked_ptr

16 // - References are only tracked as long as linked_ptr<> objects are copied.
17 // If a linked_ptr<> is converted to a raw pointer and back, BAD THINGS
21 // You can safely put linked_ptr<> in a vector<>.
24 // Note: If you use an incomplete type with linked_ptr<>, the class
25 // *containing* linked_ptr<> must have a constructor and destructor (even
29 // A linked_ptr is NOT thread safe. Copying a linked_ptr object is
32 // Alternative: to linked_ptr is shared_ptr, which
43 // This is used internally by all instances of linked_ptr<>. It needs to be
44 // a non-template class because different types of linked_ptr<> can refer to
45 // the same object (linked_ptr<Superclass>(obj) vs linked_ptr<Subclass>(obj)).
46 // So, it needs to be possible for different types of linked_ptr to participate
49 // DO NOT USE THIS CLASS DIRECTLY YOURSELF. Use linked_ptr<T>.
78 class linked_ptr {
84 explicit linked_ptr(T* ptr = NULL) { capture(ptr); }
85 ~linked_ptr() { depart(); }
87 // Copy an existing linked_ptr<>, adding ourselves to the list of references.
88 template <typename U> linked_ptr(linked_ptr<U> const& ptr) { copy(&ptr); }
90 linked_ptr(linked_ptr const& ptr) {
96 template <typename U> linked_ptr& operator=(linked_ptr<U> const& ptr) {
102 linked_ptr& operator=(linked_ptr const& ptr) {
119 // Sole ownership by this linked_ptr object is required.
131 bool operator==(linked_ptr<U> const& ptr) const {
135 bool operator!=(linked_ptr<U> const& ptr) const {
141 friend class linked_ptr;
155 template <typename U> void copy(linked_ptr<U> const* ptr) {
165 bool operator==(T* ptr, const linked_ptr<T>& x) {
170 bool operator!=(T* ptr, const linked_ptr<T>& x) {
174 // A function to convert T* into linked_ptr<T>
176 // for linked_ptr<FooBarBaz<type> >(new FooBarBaz<type>(arg))
178 linked_ptr<T> make_linked_ptr(T* ptr) {
179 return linked_ptr<T>(ptr);