Lines Matching defs:scoped_ptr

16 // Example usage (scoped_ptr<T>):
18 // scoped_ptr<Foo> foo(new Foo("wee"));
22 // scoped_ptr<Foo> foo; // No pointer managed.
35 // Example usage (scoped_ptr<T[]>):
37 // scoped_ptr<Foo[]> foo(new Foo[100]);
48 // passing by copy will NOT work. Here is an example using scoped_ptr:
50 // void TakesOwnership(scoped_ptr<Foo> arg) {
53 // scoped_ptr<Foo> CreateFoo() {
56 // return scoped_ptr<Foo>(new Foo("new"));
58 // scoped_ptr<Foo> PassThru(scoped_ptr<Foo> arg) {
63 // scoped_ptr<Foo> ptr(new Foo("yay")); // ptr manages Foo("yay").
65 // scoped_ptr<Foo> ptr2 = CreateFoo(); // ptr2 owns the return Foo.
66 // scoped_ptr<Foo> ptr3 = // ptr3 now owns what was in ptr2.
78 // scoped_ptr<Child> to initialize a scoped_ptr<Parent>:
80 // scoped_ptr<Foo> foo(new Foo());
81 // scoped_ptr<FooParent> parent(foo.Pass());
85 // scoped_ptr<Foo> CreateFoo() {
86 // scoped_ptr<FooChild> result(new FooChild());
90 // Note that PassAs<>() is implemented only for scoped_ptr<T>, but not for
91 // scoped_ptr<T[]>. This is because casting array pointers may not be safe.
114 // invokes 'delete'. The default deleter for scoped_ptr<T>.
163 // Never allow someone to declare something like scoped_ptr<int[10]>.
168 // a pointer. Can be used to store malloc-allocated pointers in scoped_ptr:
170 // scoped_ptr<int, rtc::FreeDeleter> foo_ptr(
180 // Minimal implementation of the core logic of scoped_ptr, suitable for
181 // reuse in both scoped_ptr and its specializations.
229 // dereferences the scoped_ptr when it is destroyed by a call to reset(),
294 // A scoped_ptr<T> is like a T*, except that the destructor of scoped_ptr<T>
296 // That is, scoped_ptr<T> owns the T object that it points to.
297 // Like a T*, a scoped_ptr<T> may hold either NULL or a pointer to a T object.
298 // Also like T*, scoped_ptr<T> is thread-compatible, and once you
301 // The size of scoped_ptr is small. On most compilers, when using the
302 // DefaultDeleter, sizeof(scoped_ptr<T>) == sizeof(T*). Custom deleters will
311 class scoped_ptr {
312 TALK_MOVE_ONLY_TYPE_FOR_CPP_03(scoped_ptr, RValue)
320 scoped_ptr() : impl_(NULL) { }
323 explicit scoped_ptr(element_type* p) : impl_(p) { }
326 scoped_ptr(element_type* p, const D& d) : impl_(p, d) { }
328 // Constructor. Allows construction from a scoped_ptr rvalue for a
337 // implementation of scoped_ptr.
339 scoped_ptr(scoped_ptr<U, V> other) : impl_(&other.impl_) {
344 scoped_ptr(RValue rvalue) : impl_(&rvalue.object->impl_) { }
346 // operator=. Allows assignment from a scoped_ptr rvalue for a convertible
355 // scoped_ptr.
357 scoped_ptr& operator=(scoped_ptr<U, V> rhs) {
383 // Allow scoped_ptr<element_type> to be used in boolean expressions, but not
392 scoped_ptr::*Testable;
395 operator Testable() const { return impl_.get() ? &scoped_ptr::impl_ : NULL; }
398 // These return whether two scoped_ptr refer to the same object, not just to
404 void swap(scoped_ptr& p2) {
435 scoped_ptr<PassAsType> PassAs() {
436 return scoped_ptr<PassAsType>(Pass());
441 template <typename U, typename V> friend class scoped_ptr;
445 explicit scoped_ptr(int disallow_construction_from_null);
447 // Forbid comparison of scoped_ptr types. If U != T, it totally
451 template <class U> bool operator==(scoped_ptr<U> const& p2) const;
452 template <class U> bool operator!=(scoped_ptr<U> const& p2) const;
456 class scoped_ptr<T[], D> {
457 TALK_MOVE_ONLY_TYPE_FOR_CPP_03(scoped_ptr, RValue)
465 scoped_ptr() : impl_(NULL) { }
483 explicit scoped_ptr(element_type* array) : impl_(array) { }
486 scoped_ptr(RValue rvalue) : impl_(&rvalue.object->impl_) { }
489 scoped_ptr& operator=(RValue rhs) {
509 // Allow scoped_ptr<element_type> to be used in boolean expressions, but not
513 scoped_ptr::*Testable;
516 operator Testable() const { return impl_.get() ? &scoped_ptr::impl_ : NULL; }
519 // These return whether two scoped_ptr refer to the same object, not just to
525 void swap(scoped_ptr& p2) {
561 template <typename U> explicit scoped_ptr(U* array);
562 explicit scoped_ptr(int disallow_construction_from_null);
569 // Forbid comparison of scoped_ptr types. If U != T, it totally
573 template <class U> bool operator==(scoped_ptr<U> const& p2) const;
574 template <class U> bool operator!=(scoped_ptr<U> const& p2) const;
581 void swap(rtc::scoped_ptr<T, D>& p1, rtc::scoped_ptr<T, D>& p2) {
586 bool operator==(T* p1, const rtc::scoped_ptr<T, D>& p2) {
591 bool operator!=(T* p1, const rtc::scoped_ptr<T, D>& p2) {