summaryrefslogtreecommitdiff
path: root/chromium/base/tuple.h
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-01-04 14:17:57 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-01-05 10:05:06 +0000
commit39d357e3248f80abea0159765ff39554affb40db (patch)
treeaba0e6bfb76de0244bba0f5fdbd64b830dd6e621 /chromium/base/tuple.h
parent87778abf5a1f89266f37d1321b92a21851d8244d (diff)
downloadqtwebengine-chromium-39d357e3248f80abea0159765ff39554affb40db.tar.gz
BASELINE: Update Chromium to 55.0.2883.105
And updates ninja to 1.7.2 Change-Id: I20d43c737f82764d857ada9a55586901b18b9243 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/base/tuple.h')
-rw-r--r--chromium/base/tuple.h53
1 files changed, 29 insertions, 24 deletions
diff --git a/chromium/base/tuple.h b/chromium/base/tuple.h
index e82f2e5f06a..9f62339f0d5 100644
--- a/chromium/base/tuple.h
+++ b/chromium/base/tuple.h
@@ -121,6 +121,10 @@ auto get(T& t) -> decltype(std::get<I>(t)) {
template <size_t N>
using MakeIndexSequence = typename MakeIndexSequenceImpl<N>::Type;
+template <typename T>
+using MakeIndexSequenceForTuple =
+ MakeIndexSequence<std::tuple_size<typename std::decay<T>::type>::value>;
+
// Dispatchers ----------------------------------------------------------------
//
// Helper functions that call the given method on an object, with the unpacked
@@ -132,62 +136,63 @@ using MakeIndexSequence = typename MakeIndexSequenceImpl<N>::Type;
// Non-Static Dispatchers with no out params.
-template <typename ObjT, typename Method, typename... Ts, size_t... Ns>
+template <typename ObjT, typename Method, typename Tuple, size_t... Ns>
inline void DispatchToMethodImpl(const ObjT& obj,
Method method,
- const std::tuple<Ts...>& arg,
+ Tuple&& args,
IndexSequence<Ns...>) {
- (obj->*method)(internal::Unwrap(std::get<Ns>(arg))...);
+ (obj->*method)(base::get<Ns>(std::forward<Tuple>(args))...);
}
-template <typename ObjT, typename Method, typename... Ts>
+template <typename ObjT, typename Method, typename Tuple>
inline void DispatchToMethod(const ObjT& obj,
Method method,
- const std::tuple<Ts...>& arg) {
- DispatchToMethodImpl(obj, method, arg, MakeIndexSequence<sizeof...(Ts)>());
+ Tuple&& args) {
+ DispatchToMethodImpl(obj, method, std::forward<Tuple>(args),
+ MakeIndexSequenceForTuple<Tuple>());
}
// Static Dispatchers with no out params.
-template <typename Function, typename... Ts, size_t... Ns>
+template <typename Function, typename Tuple, size_t... Ns>
inline void DispatchToFunctionImpl(Function function,
- const std::tuple<Ts...>& arg,
+ Tuple&& args,
IndexSequence<Ns...>) {
- (*function)(internal::Unwrap(std::get<Ns>(arg))...);
+ (*function)(base::get<Ns>(std::forward<Tuple>(args))...);
}
-template <typename Function, typename... Ts>
-inline void DispatchToFunction(Function function,
- const std::tuple<Ts...>& arg) {
- DispatchToFunctionImpl(function, arg, MakeIndexSequence<sizeof...(Ts)>());
+template <typename Function, typename Tuple>
+inline void DispatchToFunction(Function function, Tuple&& args) {
+ DispatchToFunctionImpl(function, std::forward<Tuple>(args),
+ MakeIndexSequenceForTuple<Tuple>());
}
// Dispatchers with out parameters.
template <typename ObjT,
typename Method,
- typename... InTs,
- typename... OutTs,
+ typename InTuple,
+ typename OutTuple,
size_t... InNs,
size_t... OutNs>
inline void DispatchToMethodImpl(const ObjT& obj,
Method method,
- const std::tuple<InTs...>& in,
- std::tuple<OutTs...>* out,
+ InTuple&& in,
+ OutTuple* out,
IndexSequence<InNs...>,
IndexSequence<OutNs...>) {
- (obj->*method)(internal::Unwrap(std::get<InNs>(in))...,
+ (obj->*method)(base::get<InNs>(std::forward<InTuple>(in))...,
&std::get<OutNs>(*out)...);
}
-template <typename ObjT, typename Method, typename... InTs, typename... OutTs>
+template <typename ObjT, typename Method, typename InTuple, typename OutTuple>
inline void DispatchToMethod(const ObjT& obj,
Method method,
- const std::tuple<InTs...>& in,
- std::tuple<OutTs...>* out) {
- DispatchToMethodImpl(obj, method, in, out,
- MakeIndexSequence<sizeof...(InTs)>(),
- MakeIndexSequence<sizeof...(OutTs)>());
+ InTuple&& in,
+ OutTuple* out) {
+ DispatchToMethodImpl(obj, method, std::forward<InTuple>(in), out,
+ MakeIndexSequenceForTuple<InTuple>(),
+ MakeIndexSequenceForTuple<OutTuple>());
}
} // namespace base