Lines Matching defs:linked_ptr

5 // This is a copy of base/linked_ptr.h with CHECKS/DCHECKS replaced with
19 // - References are only tracked as long as linked_ptr<> objects are copied.
20 // If a linked_ptr<> is converted to a raw pointer and back, BAD THINGS
24 // You can safely put linked_ptr<> in a vector<>.
27 // Note: If you use an incomplete type with linked_ptr<>, the class
28 // *containing* linked_ptr<> must have a constructor and destructor (even
32 // A linked_ptr is NOT thread safe. Copying a linked_ptr object is
35 // Alternative: to linked_ptr is shared_ptr, which
45 // This is used internally by all instances of linked_ptr<>. It needs to be
46 // a non-template class because different types of linked_ptr<> can refer to
47 // the same object (linked_ptr<Superclass>(obj) vs linked_ptr<Subclass>(obj)).
48 // So, it needs to be possible for different types of linked_ptr to participate
51 // DO NOT USE THIS CLASS DIRECTLY YOURSELF. Use linked_ptr<T>.
80 class linked_ptr {
86 explicit linked_ptr(T* ptr = NULL) { capture(ptr); }
87 ~linked_ptr() { depart(); }
89 // Copy an existing linked_ptr<>, adding ourselves to the list of references.
90 template <typename U> linked_ptr(linked_ptr<U> const& ptr) { copy(&ptr); }
92 linked_ptr(linked_ptr const& ptr) {
98 template <typename U> linked_ptr& operator=(linked_ptr<U> const& ptr) {
104 linked_ptr& operator=(linked_ptr const& ptr) {
122 // Sole ownership by this linked_ptr object is required.
135 bool operator==(linked_ptr<U> const& ptr) const {
139 bool operator!=(linked_ptr<U> const& ptr) const {
145 friend class linked_ptr;
159 template <typename U> void copy(linked_ptr<U> const* ptr) {
169 bool operator==(T* ptr, const linked_ptr<T>& x) {
174 bool operator!=(T* ptr, const linked_ptr<T>& x) {
178 // A function to convert T* into linked_ptr<T>
180 // for linked_ptr<FooBarBaz<type> >(new FooBarBaz<type>(arg))
182 linked_ptr<T> make_linked_ptr(T* ptr) {
183 return linked_ptr<T>(ptr);