17 template<
typename Tuple1,
typename Tuple2, std::size_t... I1, std::size_t... I2>
18 auto tuple_cat_impl(Tuple1&& t1, Tuple2&& t2, std::index_sequence<I1...> , std::index_sequence<I2...> ) {
19 return std::make_tuple(std::get<I1>(std::forward<Tuple1>(t1))..., std::get<I2>(std::forward<Tuple2>(t2))...);
22 template<
typename Tuple1,
typename Tuple2>
25 std::forward<Tuple1>(t1),
26 std::forward<Tuple2>(t2),
27 std::make_index_sequence<std::tuple_size<
typename std::decay<Tuple1>::type>::value>{},
28 std::make_index_sequence<std::tuple_size<typename std::decay<Tuple2>::type>::value>{}
36 template<
typename Tuple, std::size_t... I>
38 return std::make_tuple(std::get<I+1>(std::forward<Tuple>(t))...);
45 template<
typename Tuple>
47 return detail::tuple_tail_impl(std::forward<Tuple>(t), std::make_index_sequence<std::tuple_size<
typename std::decay<Tuple>::type>::value-1>{});
50 template<
typename Converter,
typename Information,
typename FOut,
typename... TOut>
57 template<
typename Tuple>
63 template<
typename Converter,
typename Information,
typename Out>
71 return std::make_tuple(Converter::template convert<Out>(std::get<0>(in),
mInfo));
79 template<
typename F,
typename Tuple, std::size_t... I>
81 return (std::forward<F>(f))(std::get<I>(std::forward<Tuple>(t))...);
89 template<
typename F,
typename Tuple>
91 return detail::tuple_apply_impl(std::forward<F>(f), std::forward<Tuple>(t), std::make_index_sequence<std::tuple_size<
typename std::decay<Tuple>::type>::value>{});
99 template<
typename F,
typename Tuple, std::size_t... I>
101 return std::make_tuple(f(std::get<I>(std::forward<Tuple>(t)))...);
109 template<
typename F,
typename Tuple>
111 return detail::tuple_foreach_impl(std::forward<F>(f), std::forward<Tuple>(t), std::make_index_sequence<std::tuple_size<
typename std::decay<Tuple>::type>::value>{});
118 template<
typename Tuple,
typename T,
typename F>
120 template<std::size_t I, typename std::enable_if<0 < I, void>::type* =
nullptr>
121 T call(Tuple&& t, T&&
init, F&& f) {
122 return std::forward<F>(f)(call<I-1>(t,
init, std::forward<F>(f)), std::get<I-1>(t));
124 template<std::size_t I, typename std::enable_if<0 == I, void>::type* =
nullptr>
125 T call(Tuple&& t, T&&
init, F&& f) {
128 T operator()(Tuple&& t, T&&
init, F&& f) {
129 return call<std::tuple_size<typename std::decay<Tuple>::type>::value>(t,
init, std::forward<F>(f));
138 template<
typename Tuple,
typename T,
typename F>
carl is the main namespace for the library.
auto tuple_cat(Tuple1 &&t1, Tuple2 &&t2)
auto tuple_apply(F &&f, Tuple &&t)
Invokes a callable object f on a tuple of arguments.
auto tuple_tail(Tuple &&t)
Returns a new tuple containing everything but the first element.
T tuple_accumulate(Tuple &&t, T &&init, F &&f)
Implements a functional fold (similar to std::accumulate) for std::tuple.
int init()
The routine for initializing the carl library.
auto tuple_foreach(F &&f, Tuple &&t)
Invokes a callable object f on every element of a tuple and returns a tuple containing the results.
auto tuple_apply_impl(F &&f, Tuple &&t, std::index_sequence< I... >)
Helper method for carl::tuple_apply that actually performs the call.
auto tuple_tail_impl(Tuple &&t, std::index_sequence< I... >)
Helper method for carl::tuple_tail that actually performs the call.
auto tuple_foreach_impl(F &&f, Tuple &&t, std::index_sequence< I... >)
Helper method for carl::tuple_foreach that actually does the work.
auto tuple_cat_impl(Tuple1 &&t1, Tuple2 &&t2, std::index_sequence< I1... >, std::index_sequence< I2... >)
Helper method for carl::tuple_apply that actually performs the call.
std::tuple< FOut, TOut... > operator()(const Tuple &in)
tuple_convert< Converter, Information, TOut... > conv
tuple_convert(const Information &i)
std::tuple< Out > operator()(const std::tuple< In > &in)
tuple_convert(const Information &i)
Helper functor for carl::tuple_accumulate that actually does the work.