| Index: webrtc/base/scoped_ptr.h
|
| diff --git a/webrtc/base/scoped_ptr.h b/webrtc/base/scoped_ptr.h
|
| index 203a00138e62de3a2473b8fd4efcfb6cb4311d29..3b3301fbea4a9663805fadfc337c220ccc414e9f 100644
|
| --- a/webrtc/base/scoped_ptr.h
|
| +++ b/webrtc/base/scoped_ptr.h
|
| @@ -42,55 +42,39 @@
|
| // }
|
| //
|
| // These scopers also implement part of the functionality of C++11 unique_ptr
|
| -// in that they are "movable but not copyable." You can use the scopers in
|
| -// the parameter and return types of functions to signify ownership transfer
|
| -// in to and out of a function. When calling a function that has a scoper
|
| -// as the argument type, it must be called with the result of an analogous
|
| -// scoper's Pass() function or another function that generates a temporary;
|
| -// passing by copy will NOT work. Here is an example using scoped_ptr:
|
| +// in that they are "movable but not copyable." You can use the scopers in the
|
| +// parameter and return types of functions to signify ownership transfer in to
|
| +// and out of a function. When calling a function that has a scoper as the
|
| +// argument type, it must be called with the result of calling std::move on an
|
| +// analogous scoper, or another function that generates a temporary; passing by
|
| +// copy will NOT work. Here is an example using scoped_ptr:
|
| //
|
| // void TakesOwnership(scoped_ptr<Foo> arg) {
|
| // // Do something with arg
|
| // }
|
| // scoped_ptr<Foo> CreateFoo() {
|
| -// // No need for calling Pass() because we are constructing a temporary
|
| +// // No need for calling std::move because we are constructing a temporary
|
| // // for the return value.
|
| // return scoped_ptr<Foo>(new Foo("new"));
|
| // }
|
| // scoped_ptr<Foo> PassThru(scoped_ptr<Foo> arg) {
|
| -// return arg.Pass();
|
| +// return std::move(arg);
|
| // }
|
| //
|
| // {
|
| // scoped_ptr<Foo> ptr(new Foo("yay")); // ptr manages Foo("yay").
|
| -// TakesOwnership(ptr.Pass()); // ptr no longer owns Foo("yay").
|
| +// TakesOwnership(std::move(ptr)); // ptr no longer owns Foo("yay").
|
| // scoped_ptr<Foo> ptr2 = CreateFoo(); // ptr2 owns the return Foo.
|
| // scoped_ptr<Foo> ptr3 = // ptr3 now owns what was in ptr2.
|
| -// PassThru(ptr2.Pass()); // ptr2 is correspondingly nullptr.
|
| +// PassThru(std::move(ptr2)); // ptr2 is correspondingly nullptr.
|
| // }
|
| //
|
| -// Notice that if you do not call Pass() when returning from PassThru(), or
|
| +// Notice that if you do not call std::move when returning from PassThru(), or
|
| // when invoking TakesOwnership(), the code will not compile because scopers
|
| // are not copyable; they only implement move semantics which require calling
|
| -// the Pass() function to signify a destructive transfer of state. CreateFoo()
|
| -// is different though because we are constructing a temporary on the return
|
| -// line and thus can avoid needing to call Pass().
|
| -//
|
| -// Pass() properly handles upcast in initialization, i.e. you can use a
|
| -// scoped_ptr<Child> to initialize a scoped_ptr<Parent>:
|
| -//
|
| -// scoped_ptr<Foo> foo(new Foo());
|
| -// scoped_ptr<FooParent> parent(foo.Pass());
|
| -//
|
| -// PassAs<>() should be used to upcast return value in return statement:
|
| -//
|
| -// scoped_ptr<Foo> CreateFoo() {
|
| -// scoped_ptr<FooChild> result(new FooChild());
|
| -// return result.PassAs<Foo>();
|
| -// }
|
| -//
|
| -// Note that PassAs<>() is implemented only for scoped_ptr<T>, but not for
|
| -// scoped_ptr<T[]>. This is because casting array pointers may not be safe.
|
| +// std::move to signify a destructive transfer of state. CreateFoo() is
|
| +// different though because we are constructing a temporary on the return line
|
| +// and thus can avoid needing to call std::move.
|
|
|
| #ifndef WEBRTC_BASE_SCOPED_PTR_H__
|
| #define WEBRTC_BASE_SCOPED_PTR_H__
|
|
|