You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by to...@apache.org on 2016/03/08 20:24:58 UTC
[1/2] incubator-kudu git commit: gutil: update
raw_scoped_refptr_mismatch_checker to use c++11
Repository: incubator-kudu
Updated Branches:
refs/heads/master 3ea58ab6c -> b37003420
gutil: update raw_scoped_refptr_mismatch_checker to use c++11
This copies the new code from chromium-base, to stop using
gutil/tuple.h. tuple.h is no longer needed, so removed it
as well.
Change-Id: Id4b2cac2bb81bf83b973304aace4238b4b9099d1
Reviewed-on: http://gerrit.cloudera.org:8080/2467
Tested-by: Kudu Jenkins
Reviewed-by: Dan Burkert <da...@cloudera.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kudu/commit/daac342d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kudu/tree/daac342d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kudu/diff/daac342d
Branch: refs/heads/master
Commit: daac342d38120745bfa485c6d72c3ac757f5b80f
Parents: 3ea58ab
Author: Todd Lipcon <to...@apache.org>
Authored: Sat Mar 5 08:37:15 2016 -0800
Committer: Todd Lipcon <to...@apache.org>
Committed: Tue Mar 8 19:24:38 2016 +0000
----------------------------------------------------------------------
build-support/release/rat_exclude_files.txt | 1 -
.../gutil/raw_scoped_refptr_mismatch_checker.h | 85 +-
src/kudu/gutil/tuple.h | 1291 ------------------
3 files changed, 10 insertions(+), 1367 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/daac342d/build-support/release/rat_exclude_files.txt
----------------------------------------------------------------------
diff --git a/build-support/release/rat_exclude_files.txt b/build-support/release/rat_exclude_files.txt
index f888c68..533f914 100644
--- a/build-support/release/rat_exclude_files.txt
+++ b/build-support/release/rat_exclude_files.txt
@@ -88,7 +88,6 @@ src/kudu/gutil/sysinfo.cc
src/kudu/gutil/sysinfo.h
src/kudu/gutil/template_util.h
src/kudu/gutil/thread_annotations.h
-src/kudu/gutil/tuple.h
src/kudu/gutil/type_traits.h
src/kudu/gutil/valgrind.h
src/kudu/gutil/auxiliary/atomicops-internals-arm-generic.h
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/daac342d/src/kudu/gutil/raw_scoped_refptr_mismatch_checker.h
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/raw_scoped_refptr_mismatch_checker.h b/src/kudu/gutil/raw_scoped_refptr_mismatch_checker.h
index 1dacd17..63e4e71 100644
--- a/src/kudu/gutil/raw_scoped_refptr_mismatch_checker.h
+++ b/src/kudu/gutil/raw_scoped_refptr_mismatch_checker.h
@@ -5,9 +5,9 @@
#ifndef KUDU_GUTIL_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_
#define KUDU_GUTIL_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_
+#include <type_traits>
+
#include "kudu/gutil/ref_counted.h"
-#include "kudu/gutil/template_util.h"
-#include "kudu/gutil/tuple.h"
// It is dangerous to post a task with a T* argument where T is a subtype of
// RefCounted(Base|ThreadSafeBase), since by the time the parameter is used, the
@@ -33,9 +33,9 @@ struct NeedsScopedRefptrButGetsRawPtr {
// Human readable translation: you needed to be a scoped_refptr if you are a
// raw pointer type and are convertible to a RefCounted(Base|ThreadSafeBase)
// type.
- value = (base::is_pointer<T>::value &&
- (base::is_convertible<T, subtle::RefCountedBase*>::value ||
- base::is_convertible<T, subtle::RefCountedThreadSafeBase*>::value))
+ value = (std::is_pointer<T>::value &&
+ (std::is_convertible<T, subtle::RefCountedBase*>::value ||
+ std::is_convertible<T, subtle::RefCountedThreadSafeBase*>::value))
};
#endif
};
@@ -46,79 +46,14 @@ struct ParamsUseScopedRefptrCorrectly {
};
template <>
-struct ParamsUseScopedRefptrCorrectly<Tuple0> {
+struct ParamsUseScopedRefptrCorrectly<std::tuple<>> {
enum { value = 1 };
};
-template <typename A>
-struct ParamsUseScopedRefptrCorrectly<Tuple1<A> > {
- enum { value = !NeedsScopedRefptrButGetsRawPtr<A>::value };
-};
-
-template <typename A, typename B>
-struct ParamsUseScopedRefptrCorrectly<Tuple2<A, B> > {
- enum { value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
- NeedsScopedRefptrButGetsRawPtr<B>::value) };
-};
-
-template <typename A, typename B, typename C>
-struct ParamsUseScopedRefptrCorrectly<Tuple3<A, B, C> > {
- enum { value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
- NeedsScopedRefptrButGetsRawPtr<B>::value ||
- NeedsScopedRefptrButGetsRawPtr<C>::value) };
-};
-
-template <typename A, typename B, typename C, typename D>
-struct ParamsUseScopedRefptrCorrectly<Tuple4<A, B, C, D> > {
- enum { value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
- NeedsScopedRefptrButGetsRawPtr<B>::value ||
- NeedsScopedRefptrButGetsRawPtr<C>::value ||
- NeedsScopedRefptrButGetsRawPtr<D>::value) };
-};
-
-template <typename A, typename B, typename C, typename D, typename E>
-struct ParamsUseScopedRefptrCorrectly<Tuple5<A, B, C, D, E> > {
- enum { value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
- NeedsScopedRefptrButGetsRawPtr<B>::value ||
- NeedsScopedRefptrButGetsRawPtr<C>::value ||
- NeedsScopedRefptrButGetsRawPtr<D>::value ||
- NeedsScopedRefptrButGetsRawPtr<E>::value) };
-};
-
-template <typename A, typename B, typename C, typename D, typename E,
- typename F>
-struct ParamsUseScopedRefptrCorrectly<Tuple6<A, B, C, D, E, F> > {
- enum { value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
- NeedsScopedRefptrButGetsRawPtr<B>::value ||
- NeedsScopedRefptrButGetsRawPtr<C>::value ||
- NeedsScopedRefptrButGetsRawPtr<D>::value ||
- NeedsScopedRefptrButGetsRawPtr<E>::value ||
- NeedsScopedRefptrButGetsRawPtr<F>::value) };
-};
-
-template <typename A, typename B, typename C, typename D, typename E,
- typename F, typename G>
-struct ParamsUseScopedRefptrCorrectly<Tuple7<A, B, C, D, E, F, G> > {
- enum { value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
- NeedsScopedRefptrButGetsRawPtr<B>::value ||
- NeedsScopedRefptrButGetsRawPtr<C>::value ||
- NeedsScopedRefptrButGetsRawPtr<D>::value ||
- NeedsScopedRefptrButGetsRawPtr<E>::value ||
- NeedsScopedRefptrButGetsRawPtr<F>::value ||
- NeedsScopedRefptrButGetsRawPtr<G>::value) };
-};
-
-template <typename A, typename B, typename C, typename D, typename E,
- typename F, typename G, typename H>
-struct ParamsUseScopedRefptrCorrectly<Tuple8<A, B, C, D, E, F, G, H> > {
- enum { value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
- NeedsScopedRefptrButGetsRawPtr<B>::value ||
- NeedsScopedRefptrButGetsRawPtr<C>::value ||
- NeedsScopedRefptrButGetsRawPtr<D>::value ||
- NeedsScopedRefptrButGetsRawPtr<E>::value ||
- NeedsScopedRefptrButGetsRawPtr<F>::value ||
- NeedsScopedRefptrButGetsRawPtr<G>::value ||
- NeedsScopedRefptrButGetsRawPtr<H>::value) };
+template <typename Head, typename... Tail>
+struct ParamsUseScopedRefptrCorrectly<std::tuple<Head, Tail...>> {
+ enum { value = !NeedsScopedRefptrButGetsRawPtr<Head>::value &&
+ ParamsUseScopedRefptrCorrectly<std::tuple<Tail...>>::value };
};
} // namespace internal
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/daac342d/src/kudu/gutil/tuple.h
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/tuple.h b/src/kudu/gutil/tuple.h
deleted file mode 100644
index e496612..0000000
--- a/src/kudu/gutil/tuple.h
+++ /dev/null
@@ -1,1291 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// A Tuple is a generic templatized container, similar in concept to std::pair.
-// There are classes Tuple0 to Tuple6, cooresponding to the number of elements
-// it contains. The convenient MakeTuple() function takes 0 to 6 arguments,
-// and will construct and return the appropriate Tuple object. The functions
-// DispatchToMethod and DispatchToFunction take a function pointer or instance
-// and method pointer, and unpack a tuple into arguments to the call.
-//
-// Tuple elements are copied by value, and stored in the tuple. See the unit
-// tests for more details of how/when the values are copied.
-//
-// Example usage:
-// // These two methods of creating a Tuple are identical.
-// Tuple2<int, const char*> tuple_a(1, "wee");
-// Tuple2<int, const char*> tuple_b = MakeTuple(1, "wee");
-//
-// void SomeFunc(int a, const char* b) { }
-// DispatchToFunction(&SomeFunc, tuple_a); // SomeFunc(1, "wee")
-// DispatchToFunction(
-// &SomeFunc, MakeTuple(10, "foo")); // SomeFunc(10, "foo")
-//
-// struct { void SomeMeth(int a, int b, int c) { } } foo;
-// DispatchToMethod(&foo, &Foo::SomeMeth, MakeTuple(1, 2, 3));
-// // foo->SomeMeth(1, 2, 3);
-
-#ifndef BASE_TUPLE_H__
-#define BASE_TUPLE_H__
-
-#include "kudu/gutil/bind_helpers.h"
-
-// Traits ----------------------------------------------------------------------
-//
-// A simple traits class for tuple arguments.
-//
-// ValueType: the bare, nonref version of a type (same as the type for nonrefs).
-// RefType: the ref version of a type (same as the type for refs).
-// ParamType: what type to pass to functions (refs should not be constified).
-
-template <class P>
-struct TupleTraits {
- typedef P ValueType;
- typedef P& RefType;
- typedef const P& ParamType;
-};
-
-template <class P>
-struct TupleTraits<P&> {
- typedef P ValueType;
- typedef P& RefType;
- typedef P& ParamType;
-};
-
-template <class P>
-struct TupleTypes { };
-
-// Tuple -----------------------------------------------------------------------
-//
-// This set of classes is useful for bundling 0 or more heterogeneous data types
-// into a single variable. The advantage of this is that it greatly simplifies
-// function objects that need to take an arbitrary number of parameters; see
-// RunnableMethod and IPC::MessageWithTuple.
-//
-// Tuple0 is supplied to act as a 'void' type. It can be used, for example,
-// when dispatching to a function that accepts no arguments (see the
-// Dispatchers below).
-// Tuple1<A> is rarely useful. One such use is when A is non-const ref that you
-// want filled by the dispatchee, and the tuple is merely a container for that
-// output (a "tier"). See MakeRefTuple and its usages.
-
-struct Tuple0 {
- typedef Tuple0 ValueTuple;
- typedef Tuple0 RefTuple;
- typedef Tuple0 ParamTuple;
-};
-
-template <class A>
-struct Tuple1 {
- public:
- typedef A TypeA;
-
- Tuple1() {}
- explicit Tuple1(typename TupleTraits<A>::ParamType a) : a(a) {}
-
- A a;
-};
-
-template <class A, class B>
-struct Tuple2 {
- public:
- typedef A TypeA;
- typedef B TypeB;
-
- Tuple2() {}
- Tuple2(typename TupleTraits<A>::ParamType a,
- typename TupleTraits<B>::ParamType b)
- : a(a), b(b) {
- }
-
- A a;
- B b;
-};
-
-template <class A, class B, class C>
-struct Tuple3 {
- public:
- typedef A TypeA;
- typedef B TypeB;
- typedef C TypeC;
-
- Tuple3() {}
- Tuple3(typename TupleTraits<A>::ParamType a,
- typename TupleTraits<B>::ParamType b,
- typename TupleTraits<C>::ParamType c)
- : a(a), b(b), c(c){
- }
-
- A a;
- B b;
- C c;
-};
-
-template <class A, class B, class C, class D>
-struct Tuple4 {
- public:
- typedef A TypeA;
- typedef B TypeB;
- typedef C TypeC;
- typedef D TypeD;
-
- Tuple4() {}
- Tuple4(typename TupleTraits<A>::ParamType a,
- typename TupleTraits<B>::ParamType b,
- typename TupleTraits<C>::ParamType c,
- typename TupleTraits<D>::ParamType d)
- : a(a), b(b), c(c), d(d) {
- }
-
- A a;
- B b;
- C c;
- D d;
-};
-
-template <class A, class B, class C, class D, class E>
-struct Tuple5 {
- public:
- typedef A TypeA;
- typedef B TypeB;
- typedef C TypeC;
- typedef D TypeD;
- typedef E TypeE;
-
- Tuple5() {}
- Tuple5(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)
- : a(a), b(b), c(c), d(d), e(e) {
- }
-
- A a;
- B b;
- C c;
- D d;
- E e;
-};
-
-template <class A, class B, class C, class D, class E, class F>
-struct Tuple6 {
- public:
- typedef A TypeA;
- typedef B TypeB;
- typedef C TypeC;
- typedef D TypeD;
- typedef E TypeE;
- typedef F TypeF;
-
- Tuple6() {}
- Tuple6(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)
- : a(a), b(b), c(c), d(d), e(e), f(f) {
- }
-
- A a;
- B b;
- C c;
- D d;
- E e;
- F f;
-};
-
-template <class A, class B, class C, class D, class E, class F, class G>
-struct Tuple7 {
- public:
- typedef A TypeA;
- typedef B TypeB;
- typedef C TypeC;
- typedef D TypeD;
- typedef E TypeE;
- typedef F TypeF;
- typedef G TypeG;
-
- Tuple7() {}
- Tuple7(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)
- : a(a), b(b), c(c), d(d), e(e), f(f), g(g) {
- }
-
- A a;
- B b;
- C c;
- D d;
- E e;
- F f;
- 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;
-
- 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 types ----------------------------------------------------------------
-//
-// Allows for selection of ValueTuple/RefTuple/ParamTuple without needing the
-// definitions of class types the tuple takes as parameters.
-
-template <>
-struct TupleTypes< Tuple0 > {
- typedef Tuple0 ValueTuple;
- typedef Tuple0 RefTuple;
- typedef Tuple0 ParamTuple;
-};
-
-template <class A>
-struct TupleTypes< Tuple1<A> > {
- typedef Tuple1<typename TupleTraits<A>::ValueType> ValueTuple;
- typedef Tuple1<typename TupleTraits<A>::RefType> RefTuple;
- typedef Tuple1<typename TupleTraits<A>::ParamType> ParamTuple;
-};
-
-template <class A, class B>
-struct TupleTypes< Tuple2<A, B> > {
- typedef Tuple2<typename TupleTraits<A>::ValueType,
- typename TupleTraits<B>::ValueType> ValueTuple;
-typedef Tuple2<typename TupleTraits<A>::RefType,
- typename TupleTraits<B>::RefType> RefTuple;
- typedef Tuple2<typename TupleTraits<A>::ParamType,
- typename TupleTraits<B>::ParamType> ParamTuple;
-};
-
-template <class A, class B, class C>
-struct TupleTypes< Tuple3<A, B, C> > {
- typedef Tuple3<typename TupleTraits<A>::ValueType,
- typename TupleTraits<B>::ValueType,
- typename TupleTraits<C>::ValueType> ValueTuple;
-typedef Tuple3<typename TupleTraits<A>::RefType,
- typename TupleTraits<B>::RefType,
- typename TupleTraits<C>::RefType> RefTuple;
- typedef Tuple3<typename TupleTraits<A>::ParamType,
- typename TupleTraits<B>::ParamType,
- typename TupleTraits<C>::ParamType> ParamTuple;
-};
-
-template <class A, class B, class C, class D>
-struct TupleTypes< Tuple4<A, B, C, D> > {
- typedef Tuple4<typename TupleTraits<A>::ValueType,
- typename TupleTraits<B>::ValueType,
- typename TupleTraits<C>::ValueType,
- typename TupleTraits<D>::ValueType> ValueTuple;
-typedef Tuple4<typename TupleTraits<A>::RefType,
- typename TupleTraits<B>::RefType,
- typename TupleTraits<C>::RefType,
- typename TupleTraits<D>::RefType> RefTuple;
- typedef Tuple4<typename TupleTraits<A>::ParamType,
- typename TupleTraits<B>::ParamType,
- typename TupleTraits<C>::ParamType,
- typename TupleTraits<D>::ParamType> ParamTuple;
-};
-
-template <class A, class B, class C, class D, class E>
-struct TupleTypes< Tuple5<A, B, C, D, E> > {
- typedef Tuple5<typename TupleTraits<A>::ValueType,
- typename TupleTraits<B>::ValueType,
- typename TupleTraits<C>::ValueType,
- typename TupleTraits<D>::ValueType,
- typename TupleTraits<E>::ValueType> ValueTuple;
-typedef Tuple5<typename TupleTraits<A>::RefType,
- typename TupleTraits<B>::RefType,
- typename TupleTraits<C>::RefType,
- typename TupleTraits<D>::RefType,
- typename TupleTraits<E>::RefType> RefTuple;
- typedef Tuple5<typename TupleTraits<A>::ParamType,
- typename TupleTraits<B>::ParamType,
- typename TupleTraits<C>::ParamType,
- typename TupleTraits<D>::ParamType,
- typename TupleTraits<E>::ParamType> ParamTuple;
-};
-
-template <class A, class B, class C, class D, class E, class F>
-struct TupleTypes< Tuple6<A, B, C, D, E, F> > {
- typedef Tuple6<typename TupleTraits<A>::ValueType,
- typename TupleTraits<B>::ValueType,
- typename TupleTraits<C>::ValueType,
- typename TupleTraits<D>::ValueType,
- typename TupleTraits<E>::ValueType,
- typename TupleTraits<F>::ValueType> ValueTuple;
-typedef Tuple6<typename TupleTraits<A>::RefType,
- typename TupleTraits<B>::RefType,
- typename TupleTraits<C>::RefType,
- typename TupleTraits<D>::RefType,
- typename TupleTraits<E>::RefType,
- typename TupleTraits<F>::RefType> RefTuple;
- typedef Tuple6<typename TupleTraits<A>::ParamType,
- typename TupleTraits<B>::ParamType,
- typename TupleTraits<C>::ParamType,
- typename TupleTraits<D>::ParamType,
- typename TupleTraits<E>::ParamType,
- typename TupleTraits<F>::ParamType> ParamTuple;
-};
-
-template <class A, class B, class C, class D, class E, class F, class G>
-struct TupleTypes< Tuple7<A, B, C, D, E, F, G> > {
- typedef Tuple7<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> ValueTuple;
-typedef Tuple7<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> RefTuple;
- typedef Tuple7<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> ParamTuple;
-};
-
-template <class A, class B, class C, class D, class E, class F, class G,
- class H>
-struct TupleTypes< Tuple8<A, B, C, D, E, F, G, H> > {
- 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;
-};
-
-// Tuple creators -------------------------------------------------------------
-//
-// Helper functions for constructing tuples while inferring the template
-// argument types.
-
-inline Tuple0 MakeTuple() {
- return Tuple0();
-}
-
-template <class A>
-inline Tuple1<A> MakeTuple(const A& a) {
- return Tuple1<A>(a);
-}
-
-template <class A, class B>
-inline Tuple2<A, B> MakeTuple(const A& a, const B& b) {
- return Tuple2<A, B>(a, b);
-}
-
-template <class A, class B, class C>
-inline Tuple3<A, B, C> MakeTuple(const A& a, const B& b, const C& c) {
- return Tuple3<A, B, C>(a, b, c);
-}
-
-template <class A, class B, class C, class D>
-inline Tuple4<A, B, C, D> MakeTuple(const A& a, const B& b, const C& c,
- const D& d) {
- return Tuple4<A, B, C, D>(a, b, c, d);
-}
-
-template <class A, class B, class C, class D, class E>
-inline Tuple5<A, B, C, D, E> MakeTuple(const A& a, const B& b, const C& c,
- const D& d, const E& e) {
- return Tuple5<A, B, C, D, E>(a, b, c, d, e);
-}
-
-template <class A, class B, class C, class D, class E, class F>
-inline Tuple6<A, B, C, D, E, F> MakeTuple(const A& a, const B& b, const C& c,
- const D& d, const E& e, const F& f) {
- return Tuple6<A, B, C, D, E, F>(a, b, c, d, e, f);
-}
-
-template <class A, class B, class C, class D, class E, class F, class G>
-inline Tuple7<A, B, C, D, E, F, G> MakeTuple(const A& a, const B& b, const C& c,
- const D& d, const E& e, const F& f,
- const G& g) {
- 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.
-
-template <class A>
-inline Tuple1<A&> MakeRefTuple(A& a) {
- return Tuple1<A&>(a);
-}
-
-template <class A, class B>
-inline Tuple2<A&, B&> MakeRefTuple(A& a, B& b) {
- return Tuple2<A&, B&>(a, b);
-}
-
-template <class A, class B, class C>
-inline Tuple3<A&, B&, C&> MakeRefTuple(A& a, B& b, C& c) {
- return Tuple3<A&, B&, C&>(a, b, c);
-}
-
-template <class A, class B, class C, class D>
-inline Tuple4<A&, B&, C&, D&> MakeRefTuple(A& a, B& b, C& c, D& d) {
- return Tuple4<A&, B&, C&, D&>(a, b, c, d);
-}
-
-template <class A, class B, class C, class D, class E>
-inline Tuple5<A&, B&, C&, D&, E&> MakeRefTuple(A& a, B& b, C& c, D& d, E& e) {
- return Tuple5<A&, B&, C&, D&, E&>(a, b, c, d, e);
-}
-
-template <class A, class B, class C, class D, class E, class F>
-inline Tuple6<A&, B&, C&, D&, E&, F&> MakeRefTuple(A& a, B& b, C& c, D& d, E& e,
- F& f) {
- return Tuple6<A&, B&, C&, D&, E&, F&>(a, b, c, d, e, f);
-}
-
-template <class A, class B, class C, class D, class E, class F, class G>
-inline Tuple7<A&, B&, C&, D&, E&, F&, G&> MakeRefTuple(A& a, B& b, C& c, D& d,
- E& e, F& f, G& g) {
- 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
-// tuple arguments. Notice that they all have the same number of arguments,
-// so you need only write:
-// DispatchToMethod(object, &Object::method, args);
-// This is very useful for templated dispatchers, since they don't need to know
-// what type |args| is.
-
-// Non-Static Dispatchers with no out params.
-
-template <class ObjT, class Method>
-inline void DispatchToMethod(ObjT* obj, Method method, const Tuple0& arg) {
- (obj->*method)();
-}
-
-template <class ObjT, class Method, class A>
-inline void DispatchToMethod(ObjT* obj, Method method, const A& arg) {
- (obj->*method)(kudu::internal::UnwrapTraits<A>::Unwrap(arg));
-}
-
-template <class ObjT, class Method, class A>
-inline void DispatchToMethod(ObjT* obj, Method method, const Tuple1<A>& arg) {
- (obj->*method)(kudu::internal::UnwrapTraits<A>::Unwrap(arg.a));
-}
-
-template<class ObjT, class Method, class A, class B>
-inline void DispatchToMethod(ObjT* obj,
- Method method,
- const Tuple2<A, B>& arg) {
- (obj->*method)(kudu::internal::UnwrapTraits<A>::Unwrap(arg.a),
- kudu::internal::UnwrapTraits<B>::Unwrap(arg.b));
-}
-
-template<class ObjT, class Method, class A, class B, class C>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple3<A, B, C>& arg) {
- (obj->*method)(kudu::internal::UnwrapTraits<A>::Unwrap(arg.a),
- kudu::internal::UnwrapTraits<B>::Unwrap(arg.b),
- kudu::internal::UnwrapTraits<C>::Unwrap(arg.c));
-}
-
-template<class ObjT, class Method, class A, class B, class C, class D>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple4<A, B, C, D>& arg) {
- (obj->*method)(kudu::internal::UnwrapTraits<A>::Unwrap(arg.a),
- kudu::internal::UnwrapTraits<B>::Unwrap(arg.b),
- kudu::internal::UnwrapTraits<C>::Unwrap(arg.c),
- kudu::internal::UnwrapTraits<D>::Unwrap(arg.d));
-}
-
-template<class ObjT, class Method, class A, class B, class C, class D, class E>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple5<A, B, C, D, E>& arg) {
- (obj->*method)(kudu::internal::UnwrapTraits<A>::Unwrap(arg.a),
- kudu::internal::UnwrapTraits<B>::Unwrap(arg.b),
- kudu::internal::UnwrapTraits<C>::Unwrap(arg.c),
- kudu::internal::UnwrapTraits<D>::Unwrap(arg.d),
- kudu::internal::UnwrapTraits<E>::Unwrap(arg.e));
-}
-
-template<class ObjT, class Method, class A, class B, class C, class D, class E,
- class F>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple6<A, B, C, D, E, F>& arg) {
- (obj->*method)(kudu::internal::UnwrapTraits<A>::Unwrap(arg.a),
- kudu::internal::UnwrapTraits<B>::Unwrap(arg.b),
- kudu::internal::UnwrapTraits<C>::Unwrap(arg.c),
- kudu::internal::UnwrapTraits<D>::Unwrap(arg.d),
- kudu::internal::UnwrapTraits<E>::Unwrap(arg.e),
- kudu::internal::UnwrapTraits<F>::Unwrap(arg.f));
-}
-
-template<class ObjT, class Method, class A, class B, class C, class D, class E,
- class F, class G>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple7<A, B, C, D, E, F, G>& arg) {
- (obj->*method)(kudu::internal::UnwrapTraits<A>::Unwrap(arg.a),
- kudu::internal::UnwrapTraits<B>::Unwrap(arg.b),
- kudu::internal::UnwrapTraits<C>::Unwrap(arg.c),
- kudu::internal::UnwrapTraits<D>::Unwrap(arg.d),
- kudu::internal::UnwrapTraits<E>::Unwrap(arg.e),
- kudu::internal::UnwrapTraits<F>::Unwrap(arg.f),
- kudu::internal::UnwrapTraits<G>::Unwrap(arg.g));
-}
-
-template<class ObjT, class Method, class A, class B, class C, class D, class E,
- class F, class G, class H>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple8<A, B, C, D, E, F, G, H>& arg) {
- (obj->*method)(kudu::internal::UnwrapTraits<A>::Unwrap(arg.a),
- kudu::internal::UnwrapTraits<B>::Unwrap(arg.b),
- kudu::internal::UnwrapTraits<C>::Unwrap(arg.c),
- kudu::internal::UnwrapTraits<D>::Unwrap(arg.d),
- kudu::internal::UnwrapTraits<E>::Unwrap(arg.e),
- kudu::internal::UnwrapTraits<F>::Unwrap(arg.f),
- kudu::internal::UnwrapTraits<G>::Unwrap(arg.g),
- kudu::internal::UnwrapTraits<H>::Unwrap(arg.h));
-}
-
-// Static Dispatchers with no out params.
-
-template <class Function>
-inline void DispatchToFunction(Function function, const Tuple0& arg) {
- (*function)();
-}
-
-template <class Function, class A>
-inline void DispatchToFunction(Function function, const A& arg) {
- (*function)(arg);
-}
-
-template <class Function, class A>
-inline void DispatchToFunction(Function function, const Tuple1<A>& arg) {
- (*function)(kudu::internal::UnwrapTraits<A>::Unwrap(arg.a));
-}
-
-template<class Function, class A, class B>
-inline void DispatchToFunction(Function function, const Tuple2<A, B>& arg) {
- (*function)(kudu::internal::UnwrapTraits<A>::Unwrap(arg.a),
- kudu::internal::UnwrapTraits<B>::Unwrap(arg.b));
-}
-
-template<class Function, class A, class B, class C>
-inline void DispatchToFunction(Function function, const Tuple3<A, B, C>& arg) {
- (*function)(kudu::internal::UnwrapTraits<A>::Unwrap(arg.a),
- kudu::internal::UnwrapTraits<B>::Unwrap(arg.b),
- kudu::internal::UnwrapTraits<C>::Unwrap(arg.c));
-}
-
-template<class Function, class A, class B, class C, class D>
-inline void DispatchToFunction(Function function,
- const Tuple4<A, B, C, D>& arg) {
- (*function)(kudu::internal::UnwrapTraits<A>::Unwrap(arg.a),
- kudu::internal::UnwrapTraits<B>::Unwrap(arg.b),
- kudu::internal::UnwrapTraits<C>::Unwrap(arg.c),
- kudu::internal::UnwrapTraits<D>::Unwrap(arg.d));
-}
-
-template<class Function, class A, class B, class C, class D, class E>
-inline void DispatchToFunction(Function function,
- const Tuple5<A, B, C, D, E>& arg) {
- (*function)(kudu::internal::UnwrapTraits<A>::Unwrap(arg.a),
- kudu::internal::UnwrapTraits<B>::Unwrap(arg.b),
- kudu::internal::UnwrapTraits<C>::Unwrap(arg.c),
- kudu::internal::UnwrapTraits<D>::Unwrap(arg.d),
- kudu::internal::UnwrapTraits<E>::Unwrap(arg.e));
-}
-
-template<class Function, class A, class B, class C, class D, class E, class F>
-inline void DispatchToFunction(Function function,
- const Tuple6<A, B, C, D, E, F>& arg) {
- (*function)(kudu::internal::UnwrapTraits<A>::Unwrap(arg.a),
- kudu::internal::UnwrapTraits<B>::Unwrap(arg.b),
- kudu::internal::UnwrapTraits<C>::Unwrap(arg.c),
- kudu::internal::UnwrapTraits<D>::Unwrap(arg.d),
- kudu::internal::UnwrapTraits<E>::Unwrap(arg.e),
- kudu::internal::UnwrapTraits<F>::Unwrap(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)(kudu::internal::UnwrapTraits<A>::Unwrap(arg.a),
- kudu::internal::UnwrapTraits<B>::Unwrap(arg.b),
- kudu::internal::UnwrapTraits<C>::Unwrap(arg.c),
- kudu::internal::UnwrapTraits<D>::Unwrap(arg.d),
- kudu::internal::UnwrapTraits<E>::Unwrap(arg.e),
- kudu::internal::UnwrapTraits<F>::Unwrap(arg.f),
- kudu::internal::UnwrapTraits<G>::Unwrap(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)(kudu::internal::UnwrapTraits<A>::Unwrap(arg.a),
- kudu::internal::UnwrapTraits<B>::Unwrap(arg.b),
- kudu::internal::UnwrapTraits<C>::Unwrap(arg.c),
- kudu::internal::UnwrapTraits<D>::Unwrap(arg.d),
- kudu::internal::UnwrapTraits<E>::Unwrap(arg.e),
- kudu::internal::UnwrapTraits<F>::Unwrap(arg.f),
- kudu::internal::UnwrapTraits<G>::Unwrap(arg.g),
- kudu::internal::UnwrapTraits<H>::Unwrap(arg.h));
-}
-
-// Dispatchers with 0 out param (as a Tuple0).
-
-template <class ObjT, class Method>
-inline void DispatchToMethod(ObjT* obj,
- Method method,
- const Tuple0& arg, Tuple0*) {
- (obj->*method)();
-}
-
-template <class ObjT, class Method, class A>
-inline void DispatchToMethod(ObjT* obj, Method method, const A& arg, Tuple0*) {
- (obj->*method)(kudu::internal::UnwrapTraits<A>::Unwrap(arg));
-}
-
-template <class ObjT, class Method, class A>
-inline void DispatchToMethod(ObjT* obj,
- Method method,
- const Tuple1<A>& arg, Tuple0*) {
- (obj->*method)(kudu::internal::UnwrapTraits<A>::Unwrap(arg.a));
-}
-
-template<class ObjT, class Method, class A, class B>
-inline void DispatchToMethod(ObjT* obj,
- Method method,
- const Tuple2<A, B>& arg, Tuple0*) {
- (obj->*method)(kudu::internal::UnwrapTraits<A>::Unwrap(arg.a),
- kudu::internal::UnwrapTraits<B>::Unwrap(arg.b));
-}
-
-template<class ObjT, class Method, class A, class B, class C>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple3<A, B, C>& arg, Tuple0*) {
- (obj->*method)(kudu::internal::UnwrapTraits<A>::Unwrap(arg.a),
- kudu::internal::UnwrapTraits<B>::Unwrap(arg.b),
- kudu::internal::UnwrapTraits<C>::Unwrap(arg.c));
-}
-
-template<class ObjT, class Method, class A, class B, class C, class D>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple4<A, B, C, D>& arg, Tuple0*) {
- (obj->*method)(kudu::internal::UnwrapTraits<A>::Unwrap(arg.a),
- kudu::internal::UnwrapTraits<B>::Unwrap(arg.b),
- kudu::internal::UnwrapTraits<C>::Unwrap(arg.c),
- kudu::internal::UnwrapTraits<D>::Unwrap(arg.d));
-}
-
-template<class ObjT, class Method, class A, class B, class C, class D, class E>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple5<A, B, C, D, E>& arg, Tuple0*) {
- (obj->*method)(kudu::internal::UnwrapTraits<A>::Unwrap(arg.a),
- kudu::internal::UnwrapTraits<B>::Unwrap(arg.b),
- kudu::internal::UnwrapTraits<C>::Unwrap(arg.c),
- kudu::internal::UnwrapTraits<D>::Unwrap(arg.d),
- kudu::internal::UnwrapTraits<E>::Unwrap(arg.e));
-}
-
-template<class ObjT, class Method, class A, class B, class C, class D, class E,
- class F>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple6<A, B, C, D, E, F>& arg, Tuple0*) {
- (obj->*method)(kudu::internal::UnwrapTraits<A>::Unwrap(arg.a),
- kudu::internal::UnwrapTraits<B>::Unwrap(arg.b),
- kudu::internal::UnwrapTraits<C>::Unwrap(arg.c),
- kudu::internal::UnwrapTraits<D>::Unwrap(arg.d),
- kudu::internal::UnwrapTraits<E>::Unwrap(arg.e),
- kudu::internal::UnwrapTraits<F>::Unwrap(arg.f));
-}
-
-// Dispatchers with 1 out param.
-
-template<class ObjT, class Method,
- class OutA>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple0& in,
- Tuple1<OutA>* out) {
- (obj->*method)(&out->a);
-}
-
-template<class ObjT, class Method, class InA,
- class OutA>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const InA& in,
- Tuple1<OutA>* out) {
- (obj->*method)(in, &out->a);
-}
-
-template<class ObjT, class Method, class InA,
- class OutA>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple1<InA>& in,
- Tuple1<OutA>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a), &out->a);
-}
-
-template<class ObjT, class Method, class InA, class InB,
- class OutA>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple2<InA, InB>& in,
- Tuple1<OutA>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- &out->a);
-}
-
-template<class ObjT, class Method, class InA, class InB, class InC,
- class OutA>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple3<InA, InB, InC>& in,
- Tuple1<OutA>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- kudu::internal::UnwrapTraits<InC>::Unwrap(in.c),
- &out->a);
-}
-
-template<class ObjT, class Method, class InA, class InB, class InC, class InD,
- class OutA>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple4<InA, InB, InC, InD>& in,
- Tuple1<OutA>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- kudu::internal::UnwrapTraits<InC>::Unwrap(in.c),
- kudu::internal::UnwrapTraits<InD>::Unwrap(in.d),
- &out->a);
-}
-
-template<class ObjT, class Method, class InA, class InB, class InC, class InD,
- class InE, class OutA>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple5<InA, InB, InC, InD, InE>& in,
- Tuple1<OutA>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- kudu::internal::UnwrapTraits<InC>::Unwrap(in.c),
- kudu::internal::UnwrapTraits<InD>::Unwrap(in.d),
- kudu::internal::UnwrapTraits<InE>::Unwrap(in.e),
- &out->a);
-}
-
-template<class ObjT, class Method,
- class InA, class InB, class InC, class InD, class InE, class InF,
- class OutA>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple6<InA, InB, InC, InD, InE, InF>& in,
- Tuple1<OutA>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- kudu::internal::UnwrapTraits<InC>::Unwrap(in.c),
- kudu::internal::UnwrapTraits<InD>::Unwrap(in.d),
- kudu::internal::UnwrapTraits<InE>::Unwrap(in.e),
- kudu::internal::UnwrapTraits<InF>::Unwrap(in.f),
- &out->a);
-}
-
-// Dispatchers with 2 out params.
-
-template<class ObjT, class Method,
- class OutA, class OutB>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple0& in,
- Tuple2<OutA, OutB>* out) {
- (obj->*method)(&out->a, &out->b);
-}
-
-template<class ObjT, class Method, class InA,
- class OutA, class OutB>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const InA& in,
- Tuple2<OutA, OutB>* out) {
- (obj->*method)(in, &out->a, &out->b);
-}
-
-template<class ObjT, class Method, class InA,
- class OutA, class OutB>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple1<InA>& in,
- Tuple2<OutA, OutB>* out) {
- (obj->*method)(
- kudu::internal::UnwrapTraits<InA>::Unwrap(in.a), &out->a, &out->b);
-}
-
-template<class ObjT, class Method, class InA, class InB,
- class OutA, class OutB>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple2<InA, InB>& in,
- Tuple2<OutA, OutB>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- &out->a,
- &out->b);
-}
-
-template<class ObjT, class Method, class InA, class InB, class InC,
- class OutA, class OutB>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple3<InA, InB, InC>& in,
- Tuple2<OutA, OutB>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- kudu::internal::UnwrapTraits<InC>::Unwrap(in.c),
- &out->a,
- &out->b);
-}
-
-template<class ObjT, class Method, class InA, class InB, class InC, class InD,
- class OutA, class OutB>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple4<InA, InB, InC, InD>& in,
- Tuple2<OutA, OutB>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- kudu::internal::UnwrapTraits<InC>::Unwrap(in.c),
- kudu::internal::UnwrapTraits<InD>::Unwrap(in.d),
- &out->a,
- &out->b);
-}
-
-template<class ObjT, class Method,
- class InA, class InB, class InC, class InD, class InE,
- class OutA, class OutB>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple5<InA, InB, InC, InD, InE>& in,
- Tuple2<OutA, OutB>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- kudu::internal::UnwrapTraits<InC>::Unwrap(in.c),
- kudu::internal::UnwrapTraits<InD>::Unwrap(in.d),
- kudu::internal::UnwrapTraits<InE>::Unwrap(in.e),
- &out->a,
- &out->b);
-}
-
-template<class ObjT, class Method,
- class InA, class InB, class InC, class InD, class InE, class InF,
- class OutA, class OutB>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple6<InA, InB, InC, InD, InE, InF>& in,
- Tuple2<OutA, OutB>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- kudu::internal::UnwrapTraits<InC>::Unwrap(in.c),
- kudu::internal::UnwrapTraits<InD>::Unwrap(in.d),
- kudu::internal::UnwrapTraits<InE>::Unwrap(in.e),
- kudu::internal::UnwrapTraits<InF>::Unwrap(in.f),
- &out->a,
- &out->b);
-}
-
-// Dispatchers with 3 out params.
-
-template<class ObjT, class Method,
- class OutA, class OutB, class OutC>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple0& in,
- Tuple3<OutA, OutB, OutC>* out) {
- (obj->*method)(&out->a, &out->b, &out->c);
-}
-
-template<class ObjT, class Method, class InA,
- class OutA, class OutB, class OutC>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const InA& in,
- Tuple3<OutA, OutB, OutC>* out) {
- (obj->*method)(in, &out->a, &out->b, &out->c);
-}
-
-template<class ObjT, class Method, class InA,
- class OutA, class OutB, class OutC>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple1<InA>& in,
- Tuple3<OutA, OutB, OutC>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- &out->a,
- &out->b,
- &out->c);
-}
-
-template<class ObjT, class Method, class InA, class InB,
- class OutA, class OutB, class OutC>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple2<InA, InB>& in,
- Tuple3<OutA, OutB, OutC>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- &out->a,
- &out->b,
- &out->c);
-}
-
-template<class ObjT, class Method, class InA, class InB, class InC,
- class OutA, class OutB, class OutC>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple3<InA, InB, InC>& in,
- Tuple3<OutA, OutB, OutC>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- kudu::internal::UnwrapTraits<InC>::Unwrap(in.c),
- &out->a,
- &out->b,
- &out->c);
-}
-
-template<class ObjT, class Method, class InA, class InB, class InC, class InD,
- class OutA, class OutB, class OutC>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple4<InA, InB, InC, InD>& in,
- Tuple3<OutA, OutB, OutC>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- kudu::internal::UnwrapTraits<InC>::Unwrap(in.c),
- kudu::internal::UnwrapTraits<InD>::Unwrap(in.d),
- &out->a,
- &out->b,
- &out->c);
-}
-
-template<class ObjT, class Method,
- class InA, class InB, class InC, class InD, class InE,
- class OutA, class OutB, class OutC>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple5<InA, InB, InC, InD, InE>& in,
- Tuple3<OutA, OutB, OutC>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- kudu::internal::UnwrapTraits<InC>::Unwrap(in.c),
- kudu::internal::UnwrapTraits<InD>::Unwrap(in.d),
- kudu::internal::UnwrapTraits<InE>::Unwrap(in.e),
- &out->a,
- &out->b,
- &out->c);
-}
-
-template<class ObjT, class Method,
- class InA, class InB, class InC, class InD, class InE, class InF,
- class OutA, class OutB, class OutC>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple6<InA, InB, InC, InD, InE, InF>& in,
- Tuple3<OutA, OutB, OutC>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- kudu::internal::UnwrapTraits<InC>::Unwrap(in.c),
- kudu::internal::UnwrapTraits<InD>::Unwrap(in.d),
- kudu::internal::UnwrapTraits<InE>::Unwrap(in.e),
- kudu::internal::UnwrapTraits<InF>::Unwrap(in.f),
- &out->a,
- &out->b,
- &out->c);
-}
-
-// Dispatchers with 4 out params.
-
-template<class ObjT, class Method,
- class OutA, class OutB, class OutC, class OutD>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple0& in,
- Tuple4<OutA, OutB, OutC, OutD>* out) {
- (obj->*method)(&out->a, &out->b, &out->c, &out->d);
-}
-
-template<class ObjT, class Method, class InA,
- class OutA, class OutB, class OutC, class OutD>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const InA& in,
- Tuple4<OutA, OutB, OutC, OutD>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in),
- &out->a,
- &out->b,
- &out->c,
- &out->d);
-}
-
-template<class ObjT, class Method, class InA,
- class OutA, class OutB, class OutC, class OutD>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple1<InA>& in,
- Tuple4<OutA, OutB, OutC, OutD>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- &out->a,
- &out->b,
- &out->c,
- &out->d);
-}
-
-template<class ObjT, class Method, class InA, class InB,
- class OutA, class OutB, class OutC, class OutD>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple2<InA, InB>& in,
- Tuple4<OutA, OutB, OutC, OutD>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- &out->a,
- &out->b,
- &out->c,
- &out->d);
-}
-
-template<class ObjT, class Method, class InA, class InB, class InC,
- class OutA, class OutB, class OutC, class OutD>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple3<InA, InB, InC>& in,
- Tuple4<OutA, OutB, OutC, OutD>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- kudu::internal::UnwrapTraits<InC>::Unwrap(in.c),
- &out->a,
- &out->b,
- &out->c,
- &out->d);
-}
-
-template<class ObjT, class Method, class InA, class InB, class InC, class InD,
- class OutA, class OutB, class OutC, class OutD>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple4<InA, InB, InC, InD>& in,
- Tuple4<OutA, OutB, OutC, OutD>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- kudu::internal::UnwrapTraits<InC>::Unwrap(in.c),
- kudu::internal::UnwrapTraits<InD>::Unwrap(in.d),
- &out->a,
- &out->b,
- &out->c,
- &out->d);
-}
-
-template<class ObjT, class Method,
- class InA, class InB, class InC, class InD, class InE,
- class OutA, class OutB, class OutC, class OutD>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple5<InA, InB, InC, InD, InE>& in,
- Tuple4<OutA, OutB, OutC, OutD>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- kudu::internal::UnwrapTraits<InC>::Unwrap(in.c),
- kudu::internal::UnwrapTraits<InD>::Unwrap(in.d),
- kudu::internal::UnwrapTraits<InE>::Unwrap(in.e),
- &out->a,
- &out->b,
- &out->c,
- &out->d);
-}
-
-template<class ObjT, class Method,
- class InA, class InB, class InC, class InD, class InE, class InF,
- class OutA, class OutB, class OutC, class OutD>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple6<InA, InB, InC, InD, InE, InF>& in,
- Tuple4<OutA, OutB, OutC, OutD>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- kudu::internal::UnwrapTraits<InC>::Unwrap(in.c),
- kudu::internal::UnwrapTraits<InD>::Unwrap(in.d),
- kudu::internal::UnwrapTraits<InE>::Unwrap(in.e),
- kudu::internal::UnwrapTraits<InF>::Unwrap(in.f),
- &out->a,
- &out->b,
- &out->c,
- &out->d);
-}
-
-// Dispatchers with 5 out params.
-
-template<class ObjT, class Method,
- class OutA, class OutB, class OutC, class OutD, class OutE>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple0& in,
- Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
- (obj->*method)(&out->a, &out->b, &out->c, &out->d, &out->e);
-}
-
-template<class ObjT, class Method, class InA,
- class OutA, class OutB, class OutC, class OutD, class OutE>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const InA& in,
- Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in),
- &out->a,
- &out->b,
- &out->c,
- &out->d,
- &out->e);
-}
-
-template<class ObjT, class Method, class InA,
- class OutA, class OutB, class OutC, class OutD, class OutE>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple1<InA>& in,
- Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- &out->a,
- &out->b,
- &out->c,
- &out->d,
- &out->e);
-}
-
-template<class ObjT, class Method, class InA, class InB,
- class OutA, class OutB, class OutC, class OutD, class OutE>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple2<InA, InB>& in,
- Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- &out->a,
- &out->b,
- &out->c,
- &out->d,
- &out->e);
-}
-
-template<class ObjT, class Method, class InA, class InB, class InC,
- class OutA, class OutB, class OutC, class OutD, class OutE>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple3<InA, InB, InC>& in,
- Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- kudu::internal::UnwrapTraits<InC>::Unwrap(in.c),
- &out->a,
- &out->b,
- &out->c,
- &out->d,
- &out->e);
-}
-
-template<class ObjT, class Method, class InA, class InB, class InC, class InD,
- class OutA, class OutB, class OutC, class OutD, class OutE>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple4<InA, InB, InC, InD>& in,
- Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- kudu::internal::UnwrapTraits<InC>::Unwrap(in.c),
- kudu::internal::UnwrapTraits<InD>::Unwrap(in.d),
- &out->a,
- &out->b,
- &out->c,
- &out->d,
- &out->e);
-}
-
-template<class ObjT, class Method,
- class InA, class InB, class InC, class InD, class InE,
- class OutA, class OutB, class OutC, class OutD, class OutE>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple5<InA, InB, InC, InD, InE>& in,
- Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- kudu::internal::UnwrapTraits<InC>::Unwrap(in.c),
- kudu::internal::UnwrapTraits<InD>::Unwrap(in.d),
- kudu::internal::UnwrapTraits<InE>::Unwrap(in.e),
- &out->a,
- &out->b,
- &out->c,
- &out->d,
- &out->e);
-}
-
-template<class ObjT, class Method,
- class InA, class InB, class InC, class InD, class InE, class InF,
- class OutA, class OutB, class OutC, class OutD, class OutE>
-inline void DispatchToMethod(ObjT* obj, Method method,
- const Tuple6<InA, InB, InC, InD, InE, InF>& in,
- Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
- (obj->*method)(kudu::internal::UnwrapTraits<InA>::Unwrap(in.a),
- kudu::internal::UnwrapTraits<InB>::Unwrap(in.b),
- kudu::internal::UnwrapTraits<InC>::Unwrap(in.c),
- kudu::internal::UnwrapTraits<InD>::Unwrap(in.d),
- kudu::internal::UnwrapTraits<InE>::Unwrap(in.e),
- kudu::internal::UnwrapTraits<InF>::Unwrap(in.f),
- &out->a,
- &out->b,
- &out->c,
- &out->d,
- &out->e);
-}
-
-#endif // BASE_TUPLE_H__
[2/2] incubator-kudu git commit: Remove gutil/algorithm.h
Posted by to...@apache.org.
Remove gutil/algorithm.h
This was included in a few places, but apparently wasn't used.
The motivation to remove it now is twofold:
a) we're on C++11 and most of these functions are implemented in <algorithm>
now
b) for the ones that aren't in C++11, apparently they aren't that generally
useful for us if we've gone several years without using them.
Change-Id: Ic4703a4b101bec940f9bb01b406aebdad70e1505
Reviewed-on: http://gerrit.cloudera.org:8080/2468
Tested-by: Kudu Jenkins
Reviewed-by: Dan Burkert <da...@cloudera.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kudu/commit/b3700342
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kudu/tree/b3700342
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kudu/diff/b3700342
Branch: refs/heads/master
Commit: b37003420fa2c1004b09170eca30428cbb92caa2
Parents: daac342
Author: Todd Lipcon <to...@apache.org>
Authored: Sat Mar 5 12:56:00 2016 -0800
Committer: Todd Lipcon <to...@apache.org>
Committed: Tue Mar 8 19:24:50 2016 +0000
----------------------------------------------------------------------
src/kudu/consensus/mt-log-test.cc | 1 -
src/kudu/gutil/algorithm.h | 441 --------------------
src/kudu/gutil/stl_util.h | 1 -
src/kudu/tablet/cfile_set.cc | 1 -
src/kudu/tablet/delta_compaction-test.cc | 1 -
src/kudu/tablet/deltafile-test.cc | 1 -
src/kudu/tablet/diskrowset-test.cc | 1 -
src/kudu/tablet/major_delta_compaction-test.cc | 1 -
src/kudu/tablet/rowset_info.cc | 1 -
9 files changed, 449 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/b3700342/src/kudu/consensus/mt-log-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/consensus/mt-log-test.cc b/src/kudu/consensus/mt-log-test.cc
index 414d258..a6e2e63 100644
--- a/src/kudu/consensus/mt-log-test.cc
+++ b/src/kudu/consensus/mt-log-test.cc
@@ -26,7 +26,6 @@
#include <vector>
#include "kudu/consensus/log_index.h"
-#include "kudu/gutil/algorithm.h"
#include "kudu/gutil/ref_counted.h"
#include "kudu/gutil/strings/substitute.h"
#include "kudu/util/locks.h"
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/b3700342/src/kudu/gutil/algorithm.h
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/algorithm.h b/src/kudu/gutil/algorithm.h
deleted file mode 100644
index ff45e98..0000000
--- a/src/kudu/gutil/algorithm.h
+++ /dev/null
@@ -1,441 +0,0 @@
-// Copyright 2006 Google Inc.
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// ---
-//
-//
-// This file contains some Google extensions to the standard
-// <algorithm> C++ header. Many of these algorithms were in the
-// original STL before it was proposed for standardization.
-
-#ifndef UTIL_GTL_ALGORITHM_H_
-#define UTIL_GTL_ALGORITHM_H_
-
-#include <stddef.h>
-#include <algorithm>
-using std::copy;
-using std::max;
-using std::min;
-using std::reverse;
-using std::sort;
-using std::swap;
-#include <functional>
-using std::binary_function;
-using std::less;
-#include <iterator>
-using std::back_insert_iterator;
-using std::iterator_traits;
-#include <utility>
-using std::make_pair;
-using std::pair;
-
-namespace util {
-namespace gtl {
-
-// Returns true if [first, last) contains an element equal to value.
-// Complexity: linear.
-template<typename InputIterator, typename EqualityComparable>
-bool contains(InputIterator first, InputIterator last,
- const EqualityComparable& value) {
- return std::find(first, last, value) != last;
-}
-
-// There is no contains_if(). Use any() instead.
-
-template<typename InputIterator, typename ForwardIterator>
-bool contains_some_of(InputIterator first1, InputIterator last1,
- ForwardIterator first2, ForwardIterator last2) {
- return std::find_first_of(first1, last1, first2, last2) != last1;
-}
-
-template<typename InputIterator, typename ForwardIterator, typename Predicate>
-bool contains_some_of(InputIterator first1, InputIterator last1,
- ForwardIterator first2, ForwardIterator last2,
- Predicate pred) {
- return std::find_first_of(first1, last1, first2, last2, pred) != last1;
-}
-
-template<typename InputIterator, typename EqualityComparable>
-typename std::iterator_traits<InputIterator>::pointer
-find_or_null(InputIterator first, InputIterator last,
- const EqualityComparable& value) {
- const InputIterator it = std::find(first, last, value);
- return it != last ? &*it : NULL;
-}
-
-template<typename InputIterator, typename Predicate>
-typename std::iterator_traits<InputIterator>::pointer
-find_if_or_null(InputIterator first, InputIterator last, Predicate pred) {
- const InputIterator it = std::find_if(first, last, pred);
- return it != last ? &*it : NULL;
-}
-
-// Copies all elements that satisfy the predicate pred from [first,
-// last) to out. This is the complement of remove_copy_if. Complexity:
-// exactly last-first applications of pred.
-template <typename InputIterator, typename OutputIterator, typename Predicate>
-OutputIterator copy_if(InputIterator first, InputIterator last,
- OutputIterator out,
- Predicate pred) {
- for (; first != last; ++first) {
- if (pred(*first))
- *out++ = *first;
- }
- return out;
-}
-
-// Copies n elements to out. Equivalent to copy(first, first + n, out) for
-// random access iterators and a longer code block for lesser iterators.
-template <typename InputIterator, typename Size, typename OutputIterator>
-OutputIterator copy_n(InputIterator first, Size n, OutputIterator out) {
- while (n > 0) {
- *out = *first;
- ++out;
- ++first;
- --n;
- }
- return out;
-}
-
-// Returns true if pred is true for every element in [first, last). Complexity:
-// at most last-first applications of pred.
-template <typename InputIterator, typename Predicate>
-bool all(InputIterator first, InputIterator last, Predicate pred) {
- for (; first != last; ++first) {
- if (!pred(*first))
- return false;
- }
- return true;
-}
-
-// Returns true if pred is false for every element in [first,
-// last). Complexity: at most last-first applications of pred.
-template <typename InputIterator, typename Predicate>
-bool none(InputIterator first, InputIterator last, Predicate pred) {
- return find_if(first, last, pred) == last;
-}
-
-// Returns true if pred is true for at least one element in [first, last).
-// Complexity: at most last-first applications of pred.
-template <typename InputIterator, typename Predicate>
-bool any(InputIterator first, InputIterator last, Predicate pred) {
- return !none(first, last, pred);
-}
-
-// Returns a pair of iterators p such that p.first points to the
-// minimum element in the range and p.second points to the maximum,
-// ordered by comp. Complexity: at most floor((3/2) (N-1))
-// comparisons. Postcondition: If the return value is <min, max>, min is
-// the first iterator i in [first, last) such that comp(*j, *i) is
-// false for every other iterator j, and max is the last iterator i
-// such that comp(*i, *j) is false for every other iterator j. Or less
-// formally, min is the first minimum and max is the last maximum.
-template <typename ForwardIter, typename Compare>
-std::pair<ForwardIter, ForwardIter> minmax_element(ForwardIter first,
- const ForwardIter last,
- Compare comp) {
- // Initialization: for N<2, set min=max=first. For N >= 2, set min
- // to be the smaller of the first two and max to be the larger. (Taking
- // care that min is the first, and max the second, if the two compare
- // equivalent.)
- ForwardIter min(first);
- ForwardIter max(first);
-
- if (first != last) {
- ++first;
- }
-
- if (first != last) {
- max = first;
- if (comp(*max, *min))
- swap(min, max);
- ++first;
- }
-
- while (first != last) {
- ForwardIter next(first);
- ++next;
-
- if (next != last) {
- // We have two elements to look at that we haven't seen already,
- // *first and *next. Compare the smaller of them with the
- // current min, and the larger against the current max. The
- // subtle point: write all of the comparisons so that, if the
- // two things being compared are equivalent, we take the first
- // one as the smaller and the last as the larger.
- if (comp(*next, *first)) {
- if (comp(*next, *min))
- min = next;
- if (!comp(*first, *max))
- max = first;
- } else {
- if (comp(*first, *min))
- min = first;
- if (!comp(*next, *max))
- max = next;
- }
- } else {
- // There is only one element left that we haven't seen already, *first.
- // Adjust min or max, as appropriate, and exit the loop.
- if (comp(*first, *min)) {
- min = first;
- } else if (!comp(*first, *max)) {
- max = first;
- }
- break;
- }
-
- first = next;
- ++first;
- }
-
- return make_pair(min, max);
-}
-
-// Returns a pair of iterators p such that p.first points to the first
-// minimum element in the range and p.second points to the last
-// maximum, ordered by operator<.
-template <typename ForwardIter>
-inline std::pair<ForwardIter, ForwardIter> minmax_element(ForwardIter first,
- ForwardIter last) {
- typedef typename std::iterator_traits<ForwardIter>::value_type value_type;
- return util::gtl::minmax_element(first, last, std::less<value_type>());
-}
-
-// Returns true if [first, last) is partitioned by pred, i.e. if all
-// elements that satisfy pred appear before those that do
-// not. Complexity: linear.
-template <typename ForwardIterator, typename Predicate>
-inline bool is_partitioned(ForwardIterator first, ForwardIterator last,
- Predicate pred) {
- for (; first != last; ++first) {
- if (!pred(*first)) {
- ++first;
- return util::gtl::none(first, last, pred);
- }
- }
- return true;
-}
-
-// Precondition: is_partitioned(first, last, pred). Returns: the
-// partition point p, i.e. an iterator mid satisfying the conditions
-// all(first, mid, pred) and none(mid, last, pred). Complexity:
-// O(log(last-first)) applications of pred.
-template <typename ForwardIterator, typename Predicate>
-ForwardIterator partition_point(ForwardIterator first, ForwardIterator last,
- Predicate pred) {
- typedef typename std::iterator_traits<ForwardIterator>::difference_type diff;
- diff n = distance(first, last);
-
- // Loop invariant: n == distance(first, last)
- while (first != last) {
- diff half = n/2;
- ForwardIterator mid = first;
- advance(mid, half);
- if (pred(*mid)) {
- first = mid;
- ++first;
- n -= half+1;
- } else {
- n = half;
- last = mid;
- }
- }
-
- return first;
-}
-
-// Copies all elements that satisfy pred to out_true and all elements
-// that don't satisfy it to out_false. Returns: a pair p such that
-// p.first is the end of the range beginning at out_t and p.second is
-// the end of the range beginning at out_f. Complexity: exactly
-// last-first applications of pred.
-template <typename InputIterator,
- typename OutputIterator1, typename OutputIterator2,
- typename Predicate>
-std::pair<OutputIterator1, OutputIterator2>
-partition_copy(InputIterator first, InputIterator last,
- OutputIterator1 out_true, OutputIterator2 out_false,
- Predicate pred) {
- for (; first != last; ++first) {
- if (pred(*first))
- *out_true++ = *first;
- else
- *out_false++ = *first;
- }
- return make_pair(out_true, out_false);
-}
-
-// Reorders elements in [first, last), so that for each consecutive group
-// of duplicate elements (according to eq predicate) the first one is left and
-// others are moved at the end of the range. Returns: iterator middle such that
-// [first, middle) contains no two consecutive elements that are duplicates and
-// [middle, last) contains elements removed from all groups. It's stable for
-// range [first, middle) meaning the order of elements are the same as order of
-// their corresponding groups in input, but the order in range [middle, last)
-// is not preserved. Function is similar to std::unique, but ensures that
-// removed elements are properly copied and accessible at the range's end.
-// Complexity: exactly last-first-1 applications of eq; at most middle-first-1
-// swap operations.
-template <typename ForwardIterator, typename Equals>
-ForwardIterator unique_partition(ForwardIterator first, ForwardIterator last,
- Equals eq) {
- first = adjacent_find(first, last, eq);
- if (first == last)
- return last;
-
- // Points to right-most element within range of unique elements being built.
- ForwardIterator result = first;
-
- // 'first' iterator goes through the sequence starting from element after
- // first equal elements pair (found by adjacent_find above).
- ++first;
- while (++first != last) {
- // If we encounter an element that isn't equal to right-most element in
- // result, then extend the range and swap this element into it.
- // Otherwise just continue incrementing 'first'.
- if (!eq(*result, *first)) {
- swap(*++result, *first);
- }
- }
- // Return past-the-end upper-bound of the resulting range.
- return ++result;
-}
-
-// Reorders elements in [first, last) range moving duplicates for each
-// consecutive group of elements to the end. Equality is checked using ==.
-template <typename ForwardIterator>
-inline ForwardIterator unique_partition(ForwardIterator first,
- ForwardIterator last) {
- typedef typename std::iterator_traits<ForwardIterator>::value_type T;
- return unique_partition(first, last, std::equal_to<T>());
-}
-
-// Samples k elements from the next n.
-// Elements have the same order in the output stream as they did on input.
-//
-// This is Algorithm S from section 3.4.2 of Knuth, TAOCP, 2nd edition.
-// My k corresponds to Knuth n-m.
-// My n corrsponds to Knuth N-t.
-//
-// RngFunctor is any functor that can be called as:
-// size_t RngFunctor(size_t x)
-// The return value is an integral value in the half-open range [0, x)
-// such that all values are equally likely. Behavior is unspecified if x==0.
-// (This function never calls RngFunctor with x==0).
-
-template <typename InputIterator, typename OutputIterator, typename RngFunctor>
-inline void sample_k_of_n(InputIterator in, size_t k, size_t n,
- RngFunctor& rng, OutputIterator out) {
- if (k > n) {
- k = n;
- }
- while (k > 0) {
- if (rng(n) < k) {
- *out++ = *in;
- k--;
- }
- ++in;
- --n;
- }
-}
-
-// Finds the longest prefix of a range that is a binary max heap with
-// respect to a given StrictWeakOrdering. If first == last, returns last.
-// Otherwise, return an iterator it such that [first,it) is a heap but
-// no longer prefix is -- in other words, first + i for the lowest i
-// such that comp(first[(i-1)/2], first[i]) returns true.
-template <typename RandomAccessIterator, typename StrictWeakOrdering>
-RandomAccessIterator gtl_is_binary_heap_until(RandomAccessIterator first,
- RandomAccessIterator last,
- StrictWeakOrdering comp) {
- if (last - first < 2) return last;
- RandomAccessIterator parent = first;
- bool is_right_child = false;
- for (RandomAccessIterator child = first + 1; child != last; ++child) {
- if (comp(*parent, *child)) return child;
- if (is_right_child) ++parent;
- is_right_child = !is_right_child;
- }
- return last;
-}
-
-// Special case of gtl_is_binary_heap_until where the order is std::less,
-// i.e., where we're working with a simple max heap.
-template <typename RandomAccessIterator>
-RandomAccessIterator gtl_is_binary_heap_until(RandomAccessIterator first,
- RandomAccessIterator last) {
- typedef typename std::iterator_traits<RandomAccessIterator>::value_type T;
- return gtl_is_binary_heap_until(first, last, std::less<T>());
-}
-
-// Checks whether a range of values is a binary heap, i.e., checks that
-// no node is less (as defined by a StrictWeakOrdering) than a child.
-template <typename RandomAccessIterator, typename StrictWeakOrdering>
-bool gtl_is_binary_heap(RandomAccessIterator begin,
- RandomAccessIterator end,
- StrictWeakOrdering comp) {
- return gtl_is_binary_heap_until(begin, end, comp) == end;
-}
-
-// Special case of gtl_is_binary_heap where the order is std::less (i.e.,
-// where we're working on a simple max heap).
-template <typename RandomAccessIterator>
-bool gtl_is_binary_heap(RandomAccessIterator begin,
- RandomAccessIterator end) {
- return gtl_is_binary_heap_until(begin, end) == end;
-}
-
-// Unqualified calls to is_heap are ambiguous with some build types,
-// namespace that can clash with names that C++11 added to ::std.
-// By calling util::gtl::is_heap, clients can avoid those errors,
-// and by using the underlying is_heap call we ensure consistency
-// with the standard library's heap implementation just in case a
-// standard library ever uses anything other than a binary heap.
-#if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus > 199711L \
- || defined(LIBCXX) || _MSC_VER >= 1600 /* Visual Studio 2010 */
-using std::is_heap;
-#elif defined __GNUC__
-/* using __gnu_cxx::is_heap; */
-#elif defined _MSC_VER
-// For old versions of MSVC++, we know by inspection that make_heap()
-// traffics in binary max heaps, so gtl_is_binary_heap is an acceptable
-// implementation for is_heap.
-template <typename RandomAccessIterator>
-bool is_heap(RandomAccessIterator begin, RandomAccessIterator end) {
- return gtl_is_binary_heap(begin, end);
-}
-
-template <typename RandomAccessIterator, typename StrictWeakOrdering>
-bool is_heap(RandomAccessIterator begin,
- RandomAccessIterator end,
- StrictWeakOrdering comp) {
- return gtl_is_binary_heap(begin, end, comp);
-}
-#else
-// We need an implementation of is_heap that matches the library's
-// implementation of make_heap() and friends. gtl_is_binary_heap will
-// *probably* work, but let's be safe and not make that assumption.
-#error No implementation of is_heap defined for this toolchain.
-#endif
-
-} // namespace gtl
-} // namespace util
-
-#endif // UTIL_GTL_ALGORITHM_H_
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/b3700342/src/kudu/gutil/stl_util.h
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/stl_util.h b/src/kudu/gutil/stl_util.h
index 68e31e9..60cb587 100644
--- a/src/kudu/gutil/stl_util.h
+++ b/src/kudu/gutil/stl_util.h
@@ -55,7 +55,6 @@ using std::vector;
#include "kudu/gutil/integral_types.h"
#include "kudu/gutil/macros.h"
#include "kudu/gutil/port.h"
-#include "kudu/gutil/algorithm.h"
// Sort and remove duplicates of an STL vector or deque.
template<class T>
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/b3700342/src/kudu/tablet/cfile_set.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/cfile_set.cc b/src/kudu/tablet/cfile_set.cc
index d950e6a..981e8b4 100644
--- a/src/kudu/tablet/cfile_set.cc
+++ b/src/kudu/tablet/cfile_set.cc
@@ -23,7 +23,6 @@
#include "kudu/cfile/cfile_util.h"
#include "kudu/cfile/cfile_writer.h"
#include "kudu/common/scan_spec.h"
-#include "kudu/gutil/algorithm.h"
#include "kudu/gutil/dynamic_annotations.h"
#include "kudu/gutil/map-util.h"
#include "kudu/gutil/stl_util.h"
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/b3700342/src/kudu/tablet/delta_compaction-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/delta_compaction-test.cc b/src/kudu/tablet/delta_compaction-test.cc
index 85f077b..87ddcc2 100644
--- a/src/kudu/tablet/delta_compaction-test.cc
+++ b/src/kudu/tablet/delta_compaction-test.cc
@@ -27,7 +27,6 @@
#include "kudu/tablet/delta_compaction.h"
#include "kudu/tablet/delta_iterator_merger.h"
#include "kudu/gutil/strings/util.h"
-#include "kudu/gutil/algorithm.h"
#include "kudu/util/test_macros.h"
#include "kudu/util/stopwatch.h"
#include "kudu/util/test_util.h"
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/b3700342/src/kudu/tablet/deltafile-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/deltafile-test.cc b/src/kudu/tablet/deltafile-test.cc
index cf8703b..af984f5 100644
--- a/src/kudu/tablet/deltafile-test.cc
+++ b/src/kudu/tablet/deltafile-test.cc
@@ -24,7 +24,6 @@
#include "kudu/tablet/delta_store.h"
#include "kudu/tablet/deltafile.h"
#include "kudu/tablet/delta_tracker.h"
-#include "kudu/gutil/algorithm.h"
#include "kudu/gutil/strings/strcat.h"
#include "kudu/util/memenv/memenv.h"
#include "kudu/util/test_macros.h"
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/b3700342/src/kudu/tablet/diskrowset-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/diskrowset-test.cc b/src/kudu/tablet/diskrowset-test.cc
index 358832a..72273fa 100644
--- a/src/kudu/tablet/diskrowset-test.cc
+++ b/src/kudu/tablet/diskrowset-test.cc
@@ -23,7 +23,6 @@
#include "kudu/common/row.h"
#include "kudu/common/schema.h"
-#include "kudu/gutil/algorithm.h"
#include "kudu/gutil/stringprintf.h"
#include "kudu/tablet/delta_compaction.h"
#include "kudu/tablet/diskrowset.h"
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/b3700342/src/kudu/tablet/major_delta_compaction-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/major_delta_compaction-test.cc b/src/kudu/tablet/major_delta_compaction-test.cc
index 1f5c69d..7c81cad 100644
--- a/src/kudu/tablet/major_delta_compaction-test.cc
+++ b/src/kudu/tablet/major_delta_compaction-test.cc
@@ -32,7 +32,6 @@
#include "kudu/tablet/tablet-test-util.h"
#include "kudu/tablet/diskrowset-test-base.h"
#include "kudu/util/test_util.h"
-#include "kudu/gutil/algorithm.h"
using std::shared_ptr;
using std::unordered_set;
http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/b3700342/src/kudu/tablet/rowset_info.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/rowset_info.cc b/src/kudu/tablet/rowset_info.cc
index 5e45f6a..ddbf12b 100644
--- a/src/kudu/tablet/rowset_info.cc
+++ b/src/kudu/tablet/rowset_info.cc
@@ -26,7 +26,6 @@
#include <glog/logging.h>
#include <inttypes.h>
-#include "kudu/gutil/algorithm.h"
#include "kudu/gutil/casts.h"
#include "kudu/gutil/endian.h"
#include "kudu/gutil/map-util.h"