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

Unified Diff: base/tuple.h

Issue 826573002: Revert "Update legacy Tuple-using code." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 | « no previous file | chrome/common/chrome_utility_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/tuple.h
diff --git a/base/tuple.h b/base/tuple.h
index 4408074335b3bd2c28b5ee5719a0b63ba262971c..a0d22454abde023b5fe298d52ac78127c6cd2d2b 100644
--- a/base/tuple.h
+++ b/base/tuple.h
@@ -124,6 +124,71 @@ struct TupleLeaf {
T x;
};
+// For legacy compatibility, we name the first 8 tuple elements "a", "b", ...
+// TODO(mdempsky): Update users to use get<N>() (crbug.com/440675).
+
+#define DEFINE_TUPLE_LEAF(N, x) \
+ template <typename T> \
+ struct TupleLeaf<N, T> { \
+ TupleLeaf() {} \
+ explicit TupleLeaf(typename TupleTraits<T>::ParamType x) : x(x) {} \
+ \
+ T& get() { return x; } \
+ const T& get() const { return x; } \
+ \
+ T x; \
+ }
+
+DEFINE_TUPLE_LEAF(0, a);
+DEFINE_TUPLE_LEAF(1, b);
+DEFINE_TUPLE_LEAF(2, c);
+DEFINE_TUPLE_LEAF(3, d);
+DEFINE_TUPLE_LEAF(4, e);
+DEFINE_TUPLE_LEAF(5, f);
+DEFINE_TUPLE_LEAF(6, g);
+DEFINE_TUPLE_LEAF(7, h);
+
+#undef DEFINE_TUPLE_LEAF
+
+// Deprecated compat aliases
+// TODO(mdempsky): Update users to just use Tuple instead (crbug.com/440675).
+
+using Tuple0 = Tuple<>;
+template <typename A>
+using Tuple1 = Tuple<A>;
+template <typename A, typename B>
+using Tuple2 = Tuple<A, B>;
+template <typename A, typename B, typename C>
+using Tuple3 = Tuple<A, B, C>;
+template <typename A, typename B, typename C, typename D>
+using Tuple4 = Tuple<A, B, C, D>;
+template <typename A, typename B, typename C, typename D, typename E>
+using Tuple5 = Tuple<A, B, C, D, E>;
+template <typename A,
+ typename B,
+ typename C,
+ typename D,
+ typename E,
+ typename F>
+using Tuple6 = Tuple<A, B, C, D, E, F>;
+template <typename A,
+ typename B,
+ typename C,
+ typename D,
+ typename E,
+ typename F,
+ typename G>
+using Tuple7 = Tuple<A, B, C, D, E, F, G>;
+template <typename A,
+ typename B,
+ typename C,
+ typename D,
+ typename E,
+ typename F,
+ typename G,
+ typename H>
+using Tuple8 = Tuple<A, B, C, D, E, F, G, H>;
+
// Tuple getters --------------------------------------------------------------
//
// Allows accessing an arbitrary tuple element by index.
« no previous file with comments | « no previous file | chrome/common/chrome_utility_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698