Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Issue 8897005: Redo r113722 - Add Pass(), which implements move semantics, to scoped_ptr, scoped_array.... (Closed)

Created:
9 years ago by awong
Modified:
9 years ago
CC:
chromium-reviews, Paweł Hajdan Jr., brettw-cc_chromium.org
Visibility:
Public.

Description

Redo r113722 - Add Pass(), which implements move semantics, to scoped_ptr, scoped_array.... Add Pass(), which implements move semantics, to scoped_ptr, scoped_array, and scoped_ptr_malloc. This modification to the scopers implements the "moveable but not copyable" semantics that were introduced in C++11's unique_ptr<>. With this, is now possible to use scopers as an argument type or a return type. This signifies, in the type system, transfer of ownership into a function or out of a function respectively. Calling, or returning such a function MUST use the temporary resultin This distinction makes it possible to avoid the implicit ownership transfer issues of auto_ptr, but still allow us to have compiler enforced ownership transfer. Also adds a Passed() helper that allows using a scoper with Bind(). BUG=96118 TEST=new unittests Original review URL: http://codereview.chromium.org/8774032 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=113922

Patch Set 1 #

Patch Set 2 : Fix stupid C++98 warning. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+653 lines, -163 lines) Patch
M base/bind_helpers.h View 8 chunks +121 lines, -31 lines 0 comments Download
M base/bind_internal.h View 78 chunks +189 lines, -78 lines 0 comments Download
M base/bind_internal.h.pump View 8 chunks +7 lines, -8 lines 0 comments Download
M base/bind_unittest.cc View 5 chunks +62 lines, -5 lines 0 comments Download
M base/callback.h View 7 chunks +28 lines, -28 lines 0 comments Download
M base/callback.h.pump View 1 chunk +1 line, -1 line 0 comments Download
M base/callback_internal.h View 2 chunks +59 lines, -0 lines 0 comments Download
M base/memory/scoped_ptr.h View 10 chunks +81 lines, -12 lines 0 comments Download
M base/memory/scoped_ptr_unittest.cc View 2 chunks +92 lines, -0 lines 0 comments Download
M chrome/common/extensions/extension_manifests_unittest.cc View 1 1 chunk +13 lines, -0 lines 0 comments Download

Messages

Total messages: 4 (0 generated)
awong
Aaron, the fancy C++ trip in scoped_ptr broke the Manifest object in extension_manifest_unittest.cc. There's a ...
9 years ago (2011-12-10 00:43:18 UTC) #1
willchan no longer on Chromium
Lgtm Sent from my iNexus. On Dec 9, 2011 4:43 PM, <ajwong@chromium.org> wrote: > Reviewers: ...
9 years ago (2011-12-10 00:55:14 UTC) #2
Aaron Boodman
LGTM Can you recommend another way to write extension_manifests_unittest.cc so that this hack would not ...
9 years ago (2011-12-10 01:48:44 UTC) #3
awong
9 years ago (2011-12-10 01:53:46 UTC) #4
On 2011/12/10 01:48:44, Aaron Boodman wrote:
> LGTM

Thanks!

> Can you recommend another way to write extension_manifests_unittest.cc so that
> this hack would not be required?
> 
> What if we pass a ptr instead of const ref.

There aren't a lot of great solutions if you want to preserve the syntax of
LoadAndExpect(Manifest(x)).  You can't use a ptr or a non-const ref because
neither of those can be used with a temporary.

You could push the overload downwards into  LoadExtension(), LoadAndExpect*()
and then make it LoadAndExpect(x).

That might be the best solution.

Powered by Google App Engine
This is Rietveld 408576698