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

Issue 8774032: Add Pass(), which implements move semantics, to scoped_ptr, scoped_array, and scoped_ptr_malloc. (Closed)

Created:
9 years ago by awong
Modified:
9 years ago
CC:
chromium-reviews, Paweł Hajdan Jr., brettw-cc_chromium.org, akalin, levin, darin (slow to review)
Visibility:
Public.

Description

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 resulting from the scoper's Pass() function. You CANNOT just pass the scoper by copy as there is still no copy constructor or assignment operator; trying to do so will yield a compilation error. 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 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=113722

Patch Set 1 #

Patch Set 2 : Bind() support Implemented #

Patch Set 3 : small fixes. #

Total comments: 2

Patch Set 4 : Fix comments, make Passed() support temporaries, fix unbound argument forwarding, add more tests. #

Total comments: 36

Patch Set 5 : Fixed spelling in comments #

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

Messages

Total messages: 10 (0 generated)
awong
This is the evolution of http://codereview.chromium.org/8224026. But now, I'm not bothering to introduce a specific ...
9 years ago (2011-12-02 23:52:34 UTC) #1
darin (slow to review)
This seems very cool to me. +1 http://codereview.chromium.org/8774032/diff/5001/base/memory/scoped_ptr.h File base/memory/scoped_ptr.h (right): http://codereview.chromium.org/8774032/diff/5001/base/memory/scoped_ptr.h#newcode62 base/memory/scoped_ptr.h:62: // Notice ...
9 years ago (2011-12-03 00:25:10 UTC) #2
awong
Ready for review. @darin: FYI, I was unable to make Passed() take a scoper by ...
9 years ago (2011-12-06 00:02:07 UTC) #3
darin (slow to review)
On Mon, Dec 5, 2011 at 4:02 PM, <ajwong@chromium.org> wrote: > Ready for review. > ...
9 years ago (2011-12-06 00:52:00 UTC) #4
awong
On Mon, Dec 5, 2011 at 4:51 PM, Darin Fisher <darin@chromium.org> wrote: > > > ...
9 years ago (2011-12-06 00:57:23 UTC) #5
willchan no longer on Chromium
I have to go stare at the move emulation code a bit later today. http://codereview.chromium.org/8774032/diff/7011/base/bind_helpers.h ...
9 years ago (2011-12-07 16:24:30 UTC) #6
darin (slow to review)
On Mon, Dec 5, 2011 at 4:56 PM, Albert J. Wong (王重傑) <ajwong@chromium.org>wrote: > On ...
9 years ago (2011-12-07 17:42:18 UTC) #7
willchan no longer on Chromium
Move emulation stuff seems fine too. It's unfortunate to introduce the macro, but I guess ...
9 years ago (2011-12-07 19:25:24 UTC) #8
awong
All fixed. For good measure, also ran it through: git diff --name-only origin/trunk | xargs ...
9 years ago (2011-12-08 21:04:09 UTC) #9
willchan no longer on Chromium
9 years ago (2011-12-09 00:11:18 UTC) #10
LGTM

Powered by Google App Engine
This is Rietveld 408576698