summaryrefslogtreecommitdiffstats
path: root/base/tuple.h
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-20 16:56:26 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-20 16:56:26 +0000
commitae894519fb448026fe45976ca8c8b59218033c89 (patch)
tree80f3b0ed123364fb165b23f2c3babb1daa010bb4 /base/tuple.h
parent13d78357b67a1ff157bae80de237d1a9796424ff (diff)
downloadchromium_src-ae894519fb448026fe45976ca8c8b59218033c89.zip
chromium_src-ae894519fb448026fe45976ca8c8b59218033c89.tar.gz
chromium_src-ae894519fb448026fe45976ca8c8b59218033c89.tar.bz2
Download code cleanup:
- choose better names for some helper methods - move code to less random places This change also adds bigger tuples support, up to Tuple8 in base/tuple.h. The plan is to stop using such big number of parameters, but for now it's not trivial. This change also fixes some UI tests, not sure why it is so. TEST=unit_tests, browser_tests, ui_tests BUG=48913 Review URL: http://codereview.chromium.org/2805091 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53053 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/tuple.h')
-rw-r--r--base/tuple.h90
1 files changed, 90 insertions, 0 deletions
diff --git a/base/tuple.h b/base/tuple.h
index b3a7515..d17d9f5 100644
--- a/base/tuple.h
+++ b/base/tuple.h
@@ -307,6 +307,65 @@ struct Tuple7 {
G g;
};
+template <class A, class B, class C, class D, class E, class F, class G,
+ class H>
+struct Tuple8 {
+ public:
+ typedef A TypeA;
+ typedef B TypeB;
+ typedef C TypeC;
+ typedef D TypeD;
+ typedef E TypeE;
+ typedef F TypeF;
+ typedef G TypeG;
+ typedef H TypeH;
+ typedef Tuple8<typename TupleTraits<A>::ValueType,
+ typename TupleTraits<B>::ValueType,
+ typename TupleTraits<C>::ValueType,
+ typename TupleTraits<D>::ValueType,
+ typename TupleTraits<E>::ValueType,
+ typename TupleTraits<F>::ValueType,
+ typename TupleTraits<G>::ValueType,
+ typename TupleTraits<H>::ValueType> ValueTuple;
+ typedef Tuple8<typename TupleTraits<A>::RefType,
+ typename TupleTraits<B>::RefType,
+ typename TupleTraits<C>::RefType,
+ typename TupleTraits<D>::RefType,
+ typename TupleTraits<E>::RefType,
+ typename TupleTraits<F>::RefType,
+ typename TupleTraits<G>::RefType,
+ typename TupleTraits<H>::RefType> RefTuple;
+ typedef Tuple8<typename TupleTraits<A>::ParamType,
+ typename TupleTraits<B>::ParamType,
+ typename TupleTraits<C>::ParamType,
+ typename TupleTraits<D>::ParamType,
+ typename TupleTraits<E>::ParamType,
+ typename TupleTraits<F>::ParamType,
+ typename TupleTraits<G>::ParamType,
+ typename TupleTraits<H>::ParamType> ParamTuple;
+
+ Tuple8() {}
+ Tuple8(typename TupleTraits<A>::ParamType a,
+ typename TupleTraits<B>::ParamType b,
+ typename TupleTraits<C>::ParamType c,
+ typename TupleTraits<D>::ParamType d,
+ typename TupleTraits<E>::ParamType e,
+ typename TupleTraits<F>::ParamType f,
+ typename TupleTraits<G>::ParamType g,
+ typename TupleTraits<H>::ParamType h)
+ : a(a), b(b), c(c), d(d), e(e), f(f), g(g), h(h) {
+ }
+
+ A a;
+ B b;
+ C c;
+ D d;
+ E e;
+ F f;
+ G g;
+ H h;
+};
+
// Tuple creators -------------------------------------------------------------
//
// Helper functions for constructing tuples while inferring the template
@@ -356,6 +415,15 @@ inline Tuple7<A, B, C, D, E, F, G> MakeTuple(const A& a, const B& b, const C& c,
return Tuple7<A, B, C, D, E, F, G>(a, b, c, d, e, f, g);
}
+template <class A, class B, class C, class D, class E, class F, class G,
+ class H>
+inline Tuple8<A, B, C, D, E, F, G, H> MakeTuple(const A& a, const B& b,
+ const C& c, const D& d,
+ const E& e, const F& f,
+ const G& g, const H& h) {
+ return Tuple8<A, B, C, D, E, F, G, H>(a, b, c, d, e, f, g, h);
+}
+
// The following set of helpers make what Boost refers to as "Tiers" - a tuple
// of references.
@@ -396,6 +464,14 @@ inline Tuple7<A&, B&, C&, D&, E&, F&, G&> MakeRefTuple(A& a, B& b, C& c, D& d,
return Tuple7<A&, B&, C&, D&, E&, F&, G&>(a, b, c, d, e, f, g);
}
+template <class A, class B, class C, class D, class E, class F, class G,
+ class H>
+inline Tuple8<A&, B&, C&, D&, E&, F&, G&, H&> MakeRefTuple(A& a, B& b, C& c,
+ D& d, E& e, F& f,
+ G& g, H& h) {
+ return Tuple8<A&, B&, C&, D&, E&, F&, G&, H&>(a, b, c, d, e, f, g, h);
+}
+
// Dispatchers ----------------------------------------------------------------
//
// Helper functions that call the given method on an object, with the unpacked
@@ -506,6 +582,20 @@ inline void DispatchToFunction(Function function,
(*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f);
}
+template<class Function, class A, class B, class C, class D, class E, class F,
+ class G>
+inline void DispatchToFunction(Function function,
+ const Tuple7<A, B, C, D, E, F, G>& arg) {
+ (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g);
+}
+
+template<class Function, class A, class B, class C, class D, class E, class F,
+ class G, class H>
+inline void DispatchToFunction(Function function,
+ const Tuple8<A, B, C, D, E, F, G, H>& arg) {
+ (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g, arg.h);
+}
+
// Dispatchers with 0 out param (as a Tuple0).
template <class ObjT, class Method>