Lines Matching defs:scoped_ptr

32 // implementation of the scoped_ptr class, and its closely-related brethren,
46 template <class C> class scoped_ptr;
51 scoped_ptr<C> make_scoped_ptr(C *);
53 // A scoped_ptr<T> is like a T*, except that the destructor of
54 // scoped_ptr<T> automatically deletes the pointer it holds (if
55 // any). That is, scoped_ptr<T> owns the T object that it points
56 // to. Like a T*, a scoped_ptr<T> may hold either NULL or a pointer to
57 // a T object. Also like T*, scoped_ptr<T> is thread-compatible, and
60 // The size of a scoped_ptr is small: sizeof(scoped_ptr<C>) == sizeof(C*)
62 class scoped_ptr {
68 // There is no way to create an uninitialized scoped_ptr.
70 explicit scoped_ptr(C* p = NULL) : ptr_(p) { }
74 ~scoped_ptr() {
103 // These return whether a scoped_ptr and a raw pointer refer to
109 void swap(scoped_ptr& p2) {
131 friend scoped_ptr<C> make_scoped_ptr<C>(C *p);
133 // Forbid comparison of scoped_ptr types. If C2 != C, it totally doesn't
136 template <class C2> bool operator==(scoped_ptr<C2> const& p2) const;
137 template <class C2> bool operator!=(scoped_ptr<C2> const& p2) const;
140 scoped_ptr(const scoped_ptr&);
141 void operator=(const scoped_ptr&);
146 inline void swap(scoped_ptr<C>& p1, scoped_ptr<C>& p2) {
151 inline bool operator==(const C* p1, const scoped_ptr<C>& p2) {
156 inline bool operator==(const C* p1, const scoped_ptr<const C>& p2) {
161 inline bool operator!=(const C* p1, const scoped_ptr<C>& p2) {
166 inline bool operator!=(const C* p1, const scoped_ptr<const C>& p2) {
171 scoped_ptr<C> make_scoped_ptr(C *p) {
172 // This does nothing but to return a scoped_ptr of the type that the passed
174 // making a scoped_ptr that is used anonymously/temporarily.) From an
175 // access control point of view, we construct an unnamed scoped_ptr here
177 // to scoped_ptr::scoped_ptr(scoped_ptr const &). However, it is guaranteed
181 return scoped_ptr<C>(p);
184 // scoped_array<C> is like scoped_ptr<C>, except that the caller must allocate
187 // As with scoped_ptr<C>, a scoped_array<C> either points to an object