summaryrefslogtreecommitdiffstats
path: root/base/callback.h
diff options
context:
space:
mode:
authorajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-21 23:14:10 +0000
committerajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-21 23:14:10 +0000
commit014d0f6be0c06b1cf87854fae5397e18c3523ada (patch)
treeadc7c2c111ed82b3cced8d20f83d88d866b732c1 /base/callback.h
parentf201486cacbcc37c11c9e812836dd570bfe8d241 (diff)
downloadchromium_src-014d0f6be0c06b1cf87854fae5397e18c3523ada.zip
chromium_src-014d0f6be0c06b1cf87854fae5397e18c3523ada.tar.gz
chromium_src-014d0f6be0c06b1cf87854fae5397e18c3523ada.tar.bz2
Redo r113722 - Add Pass(), which implements move semantics, to scoped_ptr, scoped_array....
(This undoes the revert in r114247. Win canaries still can't link, but this change has been deemed safe). 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 a function or explicit cast. 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 Review URL: http://codereview.chromium.org/9021032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115441 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/callback.h')
-rw-r--r--base/callback.h56
1 files changed, 28 insertions, 28 deletions
diff --git a/base/callback.h b/base/callback.h
index abaa438..318bff0 100644
--- a/base/callback.h
+++ b/base/callback.h
@@ -312,7 +312,7 @@ class Callback<R(A1)> : public internal::CallbackBase {
PolymorphicInvoke f =
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
- return f(bind_state_.get(), a1);
+ return f(bind_state_.get(), internal::CallbackForward(a1));
}
private:
@@ -353,8 +353,8 @@ class Callback<R(A1, A2)> : public internal::CallbackBase {
PolymorphicInvoke f =
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
- return f(bind_state_.get(), a1,
- a2);
+ return f(bind_state_.get(), internal::CallbackForward(a1),
+ internal::CallbackForward(a2));
}
private:
@@ -397,9 +397,9 @@ class Callback<R(A1, A2, A3)> : public internal::CallbackBase {
PolymorphicInvoke f =
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
- return f(bind_state_.get(), a1,
- a2,
- a3);
+ return f(bind_state_.get(), internal::CallbackForward(a1),
+ internal::CallbackForward(a2),
+ internal::CallbackForward(a3));
}
private:
@@ -444,10 +444,10 @@ class Callback<R(A1, A2, A3, A4)> : public internal::CallbackBase {
PolymorphicInvoke f =
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
- return f(bind_state_.get(), a1,
- a2,
- a3,
- a4);
+ return f(bind_state_.get(), internal::CallbackForward(a1),
+ internal::CallbackForward(a2),
+ internal::CallbackForward(a3),
+ internal::CallbackForward(a4));
}
private:
@@ -495,11 +495,11 @@ class Callback<R(A1, A2, A3, A4, A5)> : public internal::CallbackBase {
PolymorphicInvoke f =
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
- return f(bind_state_.get(), a1,
- a2,
- a3,
- a4,
- a5);
+ return f(bind_state_.get(), internal::CallbackForward(a1),
+ internal::CallbackForward(a2),
+ internal::CallbackForward(a3),
+ internal::CallbackForward(a4),
+ internal::CallbackForward(a5));
}
private:
@@ -549,12 +549,12 @@ class Callback<R(A1, A2, A3, A4, A5, A6)> : public internal::CallbackBase {
PolymorphicInvoke f =
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
- return f(bind_state_.get(), a1,
- a2,
- a3,
- a4,
- a5,
- a6);
+ return f(bind_state_.get(), internal::CallbackForward(a1),
+ internal::CallbackForward(a2),
+ internal::CallbackForward(a3),
+ internal::CallbackForward(a4),
+ internal::CallbackForward(a5),
+ internal::CallbackForward(a6));
}
private:
@@ -606,13 +606,13 @@ class Callback<R(A1, A2, A3, A4, A5, A6, A7)> : public internal::CallbackBase {
PolymorphicInvoke f =
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
- return f(bind_state_.get(), a1,
- a2,
- a3,
- a4,
- a5,
- a6,
- a7);
+ return f(bind_state_.get(), internal::CallbackForward(a1),
+ internal::CallbackForward(a2),
+ internal::CallbackForward(a3),
+ internal::CallbackForward(a4),
+ internal::CallbackForward(a5),
+ internal::CallbackForward(a6),
+ internal::CallbackForward(a7));
}
private: