18#ifndef LIVE_CELLS_UTIL_HPP
19#define LIVE_CELLS_UTIL_HPP
28 inline std::size_t hash_combine(std::size_t seed) {
41 template <
typename T,
typename... Rest>
42 std::size_t hash_combine(std::size_t seed,
const T& v,
const Rest&... rest)
44 seed ^= std::hash<T>{}(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
45 return hash_combine(seed, rest...);
54 template <
typename... Ts>
58 template <
typename T,
typename... Ts>
59 struct count_args<T, Ts...> {
60 static constexpr size_t size = 1 + count_args<Ts...>::size;
65 static constexpr size_t size = 0;
74 template <
size_t S,
typename... Ts>
76 static constexpr bool value = S == count_args<Ts...>::size;
85 template <
size_t S,
typename... Ts>
87 static constexpr bool value = count_args<Ts...>::size >= S;
97 template <
size_t S,
bool enable,
typename... As>
101 template <
size_t S,
typename A,
typename... As>
102 struct packer<S, false, A, As...> {
103 template <
typename Tuple>
104 static auto pack(
const Tuple &packed,
const A &arg,
const As&... args) {
105 return packer<S, is_size<S, As...>
::value, As...>::pack(std::tuple_cat(packed, std::make_tuple(arg)), args...);
109 template <
size_t S,
typename... As>
110 struct packer<S, true, As...> {
111 template <
typename Tuple>
112 static auto pack(
const Tuple &packed,
const As&... args) {
113 return std::make_tuple(packed, args...);
126 template <
size_t S,
typename... As>
127 auto pack(
const As&... args) {
128 static_assert(is_at_least<S, As...>
::value,
"Not enough arguments provided to pack()");
130 return packer<S, is_size<S, As...>
::value, As...>::pack(std::make_tuple(), args...);
142 template <
typename F,
typename Tuple, std::size_t... I>
143 auto unpack(
const F &fn,
const Tuple &args, std::index_sequence<I...>) {
144 return fn(std::get<I>(args)...);
147 template <
typename F,
typename Tuple>
148 auto unpack(
const F &fn,
const Tuple &args) {
149 constexpr auto size = std::tuple_size<Tuple>::value;
150 return unpack(fn, args, std::make_index_sequence<size>());
Definition boolean.hpp:26
constant_cell< T > value(const T &value)
Definition constant_cell.hpp:132