diff options
author | tzik <tzik@chromium.org> | 2016-02-11 02:24:45 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-11 10:26:28 +0000 |
commit | 9ca3021996e87ad03adf4451fd7fc7f8097c8f46 (patch) | |
tree | a1c2fd07c8ea0858cbd6880c834a57ed1a6eadb1 /base/tuple.h | |
parent | fbcb7dcadf19f4c20217365b3af0a34d66511b49 (diff) | |
download | chromium_src-9ca3021996e87ad03adf4451fd7fc7f8097c8f46.zip chromium_src-9ca3021996e87ad03adf4451fd7fc7f8097c8f46.tar.gz chromium_src-9ca3021996e87ad03adf4451fd7fc7f8097c8f46.tar.bz2 |
Replace base::Tuple implementation with std::tuple
* Remove base::Tuple and make base::Tuple as an alias of std::tuple.
* Expand the alias where it's used in a class template specialization to avoid MSVC2013 internal compiler error.
BUG=554987
Review URL: https://codereview.chromium.org/1673563002
Cr-Commit-Position: refs/heads/master@{#374878}
Diffstat (limited to 'base/tuple.h')
-rw-r--r-- | base/tuple.h | 55 |
1 files changed, 3 insertions, 52 deletions
diff --git a/base/tuple.h b/base/tuple.h index e5872cc..e73dd49c 100644 --- a/base/tuple.h +++ b/base/tuple.h @@ -29,6 +29,7 @@ #define BASE_TUPLE_H_ #include <stddef.h> +#include <tuple> #include "base/bind_helpers.h" #include "build/build_config.h" @@ -145,60 +146,10 @@ struct TupleTraits<P&> { // want filled by the dispatchee, and the tuple is merely a container for that // output (a "tier"). See MakeRefTuple and its usages. -template <typename IxSeq, typename... Ts> -struct TupleBaseImpl; template <typename... Ts> -using TupleBase = TupleBaseImpl<MakeIndexSequence<sizeof...(Ts)>, Ts...>; -template <size_t N, typename T> -struct TupleLeaf; +using Tuple = std::tuple<Ts...>; -template <typename... Ts> -struct Tuple final : TupleBase<Ts...> { - Tuple() : TupleBase<Ts...>() {} - explicit Tuple(typename TupleTraits<Ts>::ParamType... args) - : TupleBase<Ts...>(args...) {} -}; - -// Avoids ambiguity between Tuple's two constructors. -template <> -struct Tuple<> final {}; - -template <size_t... Ns, typename... Ts> -struct TupleBaseImpl<IndexSequence<Ns...>, Ts...> : TupleLeaf<Ns, Ts>... { - TupleBaseImpl() : TupleLeaf<Ns, Ts>()... {} - explicit TupleBaseImpl(typename TupleTraits<Ts>::ParamType... args) - : TupleLeaf<Ns, Ts>(args)... {} -}; - -template <size_t N, typename T> -struct TupleLeaf { - TupleLeaf() {} - explicit TupleLeaf(typename TupleTraits<T>::ParamType x) : x(x) {} - - T& get() { return x; } - const T& get() const { return x; } - - T x; -}; - -// Tuple getters -------------------------------------------------------------- -// -// Allows accessing an arbitrary tuple element by index. -// -// Example usage: -// base::Tuple<int, double> t2; -// base::get<0>(t2) = 42; -// base::get<1>(t2) = 3.14; - -template <size_t I, typename T> -T& get(TupleLeaf<I, T>& leaf) { - return leaf.get(); -} - -template <size_t I, typename T> -const T& get(const TupleLeaf<I, T>& leaf) { - return leaf.get(); -} +using std::get; // Tuple types ---------------------------------------------------------------- // |