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

Unified Diff: base/bind_helpers.h

Issue 1498973002: WIP: base::Bind for rvalue references. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/bind.h ('k') | base/bind_internal.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/bind_helpers.h
diff --git a/base/bind_helpers.h b/base/bind_helpers.h
index 24063ad1ce58fd27c5535ec81c294c597db841df..370dac8a42f299f5d4454116ee87c2b9d9420557 100644
--- a/base/bind_helpers.h
+++ b/base/bind_helpers.h
@@ -384,11 +384,31 @@ class PassedWrapper {
// Unwrap the stored parameters for the wrappers above.
template <typename T>
-struct UnwrapTraits {
+struct MoveOnlyUnwrapTraits {
+ typedef T&& ForwardType;
+ static ForwardType Unwrap(T& o) { return std::move(o); }
+};
+
+template <typename T>
+struct CopyUnwrapTraits {
typedef const T& ForwardType;
static ForwardType Unwrap(const T& o) { return o; }
};
+// BindState<>
+template <typename T, typename U = void>
+struct UnwrapTraits : public std::conditional<base::is_move_only<T>::value,
+ MoveOnlyUnwrapTraits<T>,
+ CopyUnwrapTraits<T>>::type {};
+
+template <typename T>
+struct UnwrapTraits<
+ T,
+ typename std::conditional<false, typename T::value_type, void>::type>
+ : public std::conditional<base::is_move_only<typename T::value_type>::value,
+ MoveOnlyUnwrapTraits<T>,
+ CopyUnwrapTraits<T>>::type {};
+
template <typename T>
struct UnwrapTraits<UnretainedWrapper<T> > {
typedef T* ForwardType;
« no previous file with comments | « base/bind.h ('k') | base/bind_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698