21 #define ENABLE_IF(x) typename std::enable_if<(x), bool>::type 24 template <std::size_t N,
typename... Args,
typename Iterator>
25 ENABLE_IF(N == 0) iterate(std::tuple<Args...>&, Iterator&&)
31 template <std::size_t N,
typename... Args,
typename Iterator>
32 ENABLE_IF(N >= 1) iterate(std::tuple<Args...>& tup, Iterator&& it)
34 if (iterate<N - 1>(tup, it)) {
35 auto&& val = std::get<N-1>(tup);
45 template <std::size_t N,
typename... Args,
typename Iterator>
46 ENABLE_IF(N == 0) iterate(
const std::tuple<Args...>&, Iterator&)
52 template <std::size_t N,
typename... Args,
typename Iterator>
53 ENABLE_IF(N >= 1) iterate(
const std::tuple<Args...>& tup, Iterator& it)
55 if (iterate<N - 1>(tup, it)) {
56 auto&& val = std::get<N-1>(tup);
72 template<
typename Func,
typename... Args>
73 bool for_each_tuple(std::tuple<Args...>& tup, Func&& func)
75 return detail::iterate<
sizeof...(Args)>(tup, func);
79 template<
typename Func,
typename... Args>
80 bool for_each_tuple(
const std::tuple<Args...>& tup, Func&& func)
82 return detail::iterate<
sizeof...(Args)>(tup, func);
87 template<std::
size_t N>
90 static auto ref_to_members(Tuple&& tup,
int ix)
93 std::tie( std::get<N-1>(tup)[ix] ) );
100 template<
class Tuple>
101 static std::tuple<> ref_to_members(Tuple&&,
int)
104 return std::tuple<>();
120 inline void hash_combine(std::size_t& seed, T
const& v)
122 seed ^= hash<T>()(v) + 0x9e3779b9 + (seed<<6) + (seed>>2);
126 template <class Tuple, size_t Index = std::tuple_size<Tuple>::value - 1>
129 static void apply(
size_t& seed, Tuple
const& tuple)
131 HashValueImpl<Tuple, Index-1>::apply(seed, tuple);
132 hash_combine(seed, get<Index>(tuple));
136 template <
class Tuple>
137 struct HashValueImpl<Tuple,0>
139 static void apply(
size_t& seed, Tuple
const& tuple)
141 hash_combine(seed, get<0>(tuple));
148 template <
typename ... TT>
149 struct hash<
std::tuple<TT...>>
151 size_t operator()(std::tuple<TT...>
const& tt)
const 154 HashValueImpl<std::tuple<TT...>>::apply(seed, tt);
Definition: tuple_util.hpp:16
Definition: tuple_util.hpp:88
Definition: coroutine.hpp:18