Lines Matching defs:scoped_ptr

11 // Borrowed from Chromium's src/base/memory/scoped_ptr.h.
18 // Example usage (scoped_ptr<T>):
20 // scoped_ptr<Foo> foo(new Foo("wee"));
24 // scoped_ptr<Foo> foo; // No pointer managed.
37 // Example usage (scoped_ptr<T[]>):
39 // scoped_ptr<Foo[]> foo(new Foo[100]);
50 // passing by copy will NOT work. Here is an example using scoped_ptr:
52 // void TakesOwnership(scoped_ptr<Foo> arg) {
55 // scoped_ptr<Foo> CreateFoo() {
58 // return scoped_ptr<Foo>(new Foo("new"));
60 // scoped_ptr<Foo> PassThru(scoped_ptr<Foo> arg) {
65 // scoped_ptr<Foo> ptr(new Foo("yay")); // ptr manages Foo("yay").
67 // scoped_ptr<Foo> ptr2 = CreateFoo(); // ptr2 owns the return Foo.
68 // scoped_ptr<Foo> ptr3 = // ptr3 now owns what was in ptr2.
80 // scoped_ptr<Child> to initialize a scoped_ptr<Parent>:
82 // scoped_ptr<Foo> foo(new Foo());
83 // scoped_ptr<FooParent> parent(foo.Pass());
87 // scoped_ptr<Foo> CreateFoo() {
88 // scoped_ptr<FooChild> result(new FooChild());
92 // Note that PassAs<>() is implemented only for scoped_ptr<T>, but not for
93 // scoped_ptr<T[]>. This is because casting array pointers may not be safe.
99 // implementation of the scoped_ptr class.
117 // invokes 'delete'. The default deleter for scoped_ptr<T>.
166 // Never allow someone to declare something like scoped_ptr<int[10]>.
171 // a pointer. Can be used to store malloc-allocated pointers in scoped_ptr:
173 // scoped_ptr<int, webrtc::FreeDeleter> foo_ptr(
183 // Minimal implementation of the core logic of scoped_ptr, suitable for
184 // reuse in both scoped_ptr and its specializations.
231 // dereferences the scoped_ptr when it is destroyed by a call to reset(),
287 // A scoped_ptr<T> is like a T*, except that the destructor of scoped_ptr<T>
289 // That is, scoped_ptr<T> owns the T object that it points to.
290 // Like a T*, a scoped_ptr<T> may hold either NULL or a pointer to a T object.
291 // Also like T*, scoped_ptr<T> is thread-compatible, and once you
294 // The size of scoped_ptr is small. On most compilers, when using the
295 // DefaultDeleter, sizeof(scoped_ptr<T>) == sizeof(T*). Custom deleters will
304 class scoped_ptr {
305 WEBRTC_MOVE_ONLY_TYPE_FOR_CPP_03(scoped_ptr, RValue)
313 scoped_ptr() : impl_(NULL) { }
316 explicit scoped_ptr(element_type* p) : impl_(p) { }
319 scoped_ptr(element_type* p, const D& d) : impl_(p, d) { }
321 // Constructor. Allows construction from a scoped_ptr rvalue for a
330 // implementation of scoped_ptr.
332 scoped_ptr(scoped_ptr<U, V> other) : impl_(&other.impl_) {
337 scoped_ptr(RValue rvalue) : impl_(&rvalue.object->impl_) { }
339 // operator=. Allows assignment from a scoped_ptr rvalue for a convertible
348 // scoped_ptr.
350 scoped_ptr& operator=(scoped_ptr<U, V> rhs) {
376 // Allow scoped_ptr<element_type> to be used in boolean expressions, but not
385 scoped_ptr::*Testable;
388 operator Testable() const { return impl_.get() ? &scoped_ptr::impl_ : NULL; }
391 // These return whether two scoped_ptr refer to the same object, not just to
397 void swap(scoped_ptr& p2) {
417 scoped_ptr<PassAsType> PassAs() {
418 return scoped_ptr<PassAsType>(Pass());
423 template <typename U, typename V> friend class scoped_ptr;
427 explicit scoped_ptr(int disallow_construction_from_null);
429 // Forbid comparison of scoped_ptr types. If U != T, it totally
433 template <class U> bool operator==(scoped_ptr<U> const& p2) const;
434 template <class U> bool operator!=(scoped_ptr<U> const& p2) const;
438 class scoped_ptr<T[], D> {
439 WEBRTC_MOVE_ONLY_TYPE_FOR_CPP_03(scoped_ptr, RValue)
447 scoped_ptr() : impl_(NULL) { }
465 explicit scoped_ptr(element_type* array) : impl_(array) { }
468 scoped_ptr(RValue rvalue) : impl_(&rvalue.object->impl_) { }
471 scoped_ptr& operator=(RValue rhs) {
491 // Allow scoped_ptr<element_type> to be used in boolean expressions, but not
495 scoped_ptr::*Testable;
498 operator Testable() const { return impl_.get() ? &scoped_ptr::impl_ : NULL; }
501 // These return whether two scoped_ptr refer to the same object, not just to
507 void swap(scoped_ptr& p2) {
532 template <typename U> explicit scoped_ptr(U* array);
533 explicit scoped_ptr(int disallow_construction_from_null);
540 // Forbid comparison of scoped_ptr types. If U != T, it totally
544 template <class U> bool operator==(scoped_ptr<U> const& p2) const;
545 template <class U> bool operator!=(scoped_ptr<U> const& p2) const;
552 void swap(webrtc::scoped_ptr<T, D>& p1, webrtc::scoped_ptr<T, D>& p2) {
557 bool operator==(T* p1, const webrtc::scoped_ptr<T, D>& p2) {
562 bool operator!=(T* p1, const webrtc::scoped_ptr<T, D>& p2) {