Lines Matching defs:linked_ptr

43 // - References are only tracked as long as linked_ptr<> objects are copied.
44 // If a linked_ptr<> is converted to a raw pointer and back, BAD THINGS
48 // You can safely put linked_ptr<> in a vector<>.
51 // Note: If you use an incomplete type with linked_ptr<>, the class
52 // *containing* linked_ptr<> must have a constructor and destructor (even
58 // Unlike other linked_ptr implementations, in this implementation
59 // a linked_ptr object is thread-safe in the sense that:
60 // - it's safe to copy linked_ptr objects concurrently,
61 // - it's safe to copy *from* a linked_ptr and read its underlying
66 // confusion with normal linked_ptr.
79 // Protects copying of all linked_ptr objects.
82 // This is used internally by all instances of linked_ptr<>. It needs to be
83 // a non-template class because different types of linked_ptr<> can refer to
84 // the same object (linked_ptr<Superclass>(obj) vs linked_ptr<Subclass>(obj)).
85 // So, it needs to be possible for different types of linked_ptr to participate
88 // DO NOT USE THIS CLASS DIRECTLY YOURSELF. Use linked_ptr<T>.
96 // Many linked_ptr operations may change p.link_ for some linked_ptr
100 // Note that different types of linked_ptr objects can coexist in a
101 // circle (e.g. linked_ptr<Base>, linked_ptr<Derived1>, and
102 // linked_ptr<Derived2>). Therefore we must use a single mutex to
103 // protect all linked_ptr objects. This can create serious
136 class linked_ptr {
142 explicit linked_ptr(T* ptr = NULL) { capture(ptr); }
143 ~linked_ptr() { depart(); }
145 // Copy an existing linked_ptr<>, adding ourselves to the list of references.
146 template <typename U> linked_ptr(linked_ptr<U> const& ptr) { copy(&ptr); }
147 linked_ptr(linked_ptr const& ptr) { // NOLINT
153 template <typename U> linked_ptr& operator=(linked_ptr<U> const& ptr) {
159 linked_ptr& operator=(linked_ptr const& ptr) {
179 bool operator==(linked_ptr<U> const& ptr) const {
183 bool operator!=(linked_ptr<U> const& ptr) const {
189 friend class linked_ptr;
203 template <typename U> void copy(linked_ptr<U> const* ptr) {
213 bool operator==(T* ptr, const linked_ptr<T>& x) {
218 bool operator!=(T* ptr, const linked_ptr<T>& x) {
222 // A function to convert T* into linked_ptr<T>
224 // for linked_ptr<FooBarBaz<type> >(new FooBarBaz<type>(arg))
226 linked_ptr<T> make_linked_ptr(T* ptr) {
227 return linked_ptr<T>(ptr);