Lines Matching refs: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
20 // Note: If you use an incomplete type with linked_ptr<>, the class
21 // *containing* linked_ptr<> must have a constructor and destructor (even
25 // A linked_ptr is NOT thread safe. Copying a linked_ptr object is
28 // Alternative: to linked_ptr is shared_ptr, which
38 // This is used internally by all instances of linked_ptr<>. It needs to be
39 // a non-template class because different types of linked_ptr<> can refer to
40 // the same object (linked_ptr<Superclass>(obj) vs linked_ptr<Subclass>(obj)).
41 // So, it needs to be possible for different types of linked_ptr to participate
44 // DO NOT USE THIS CLASS DIRECTLY YOURSELF. Use linked_ptr<T>.
75 class linked_ptr {
81 explicit linked_ptr(T* ptr = NULL) { capture(ptr); }
82 ~linked_ptr() { depart(); }
84 // Copy an existing linked_ptr<>, adding ourselves to the list of references.
85 template <typename U> linked_ptr(linked_ptr<U> const& ptr) { copy(&ptr); }
87 linked_ptr(linked_ptr const& ptr) {
93 template <typename U> linked_ptr& operator=(linked_ptr<U> const& ptr) {
99 linked_ptr& operator=(linked_ptr const& ptr) {
116 // Sole ownership by this linked_ptr object is required.
128 bool operator==(linked_ptr<U> const& ptr) const {
132 bool operator!=(linked_ptr<U> const& ptr) const {
138 friend class linked_ptr;
152 template <typename U> void copy(linked_ptr<U> const* ptr) {
162 bool operator==(T* ptr, const linked_ptr<T>& x) {
167 bool operator!=(T* ptr, const linked_ptr<T>& x) {
171 // A function to convert T* into linked_ptr<T>
173 // for linked_ptr<FooBarBaz<type> >(new FooBarBaz<type>(arg))
175 linked_ptr<T> make_linked_ptr(T* ptr) {
176 return linked_ptr<T>(ptr);