Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fold_right_tuple.hpp
Go to the documentation of this file.
1 /*******************************************************************************
2  * tlx/meta/fold_right_tuple.hpp
3  *
4  * Part of tlx - http://panthema.net/tlx
5  *
6  * Copyright (C) 2018 Hung Tran <[email protected]>
7  *
8  * All rights reserved. Published under the Boost Software License, Version 1.0
9  ******************************************************************************/
10 
11 #ifndef TLX_META_FOLD_RIGHT_TUPLE_HEADER
12 #define TLX_META_FOLD_RIGHT_TUPLE_HEADER
13 
14 #include <tlx/meta/fold_right.hpp>
16 #include <tuple>
17 
18 namespace tlx {
19 
20 //! \addtogroup tlx_meta
21 //! \{
22 
23 /******************************************************************************/
24 // Variadic Template Expander: Implements fold_right() on the components of a
25 // tuple.
26 
27 namespace meta_detail {
28 
29 //! helper for fold_right_tuple: forwards tuple entries
30 template <typename Reduce, typename Initial, typename Tuple, std::size_t... Is>
31 auto fold_right_tuple_impl(Reduce&& r, Initial&& init, Tuple&& t,
33  return fold_right(std::forward<Reduce>(r), std::forward<Initial>(init),
34  std::get<Is>(std::forward<Tuple>(t)) ...);
35 }
36 
37 } // namespace meta_detail
38 
39 //! Implements fold_right() -- (a * (b * c)) -- with a binary Reduce operation
40 //! and initial value on a tuple.
41 template <typename Reduce, typename Initial, typename Tuple>
42 auto fold_right_tuple(Reduce&& r, Initial&& init, Tuple&& t) {
43  using Indices = make_index_sequence<
44  std::tuple_size<typename std::decay<Tuple>::type>::value>;
46  std::forward<Reduce>(r), std::forward<Initial>(init),
47  std::forward<Tuple>(t), Indices());
48 }
49 
50 //! \}
51 
52 } // namespace tlx
53 
54 #endif // !TLX_META_FOLD_RIGHT_TUPLE_HEADER
55 
56 /******************************************************************************/
auto fold_right_tuple_impl(Reduce &&r, Initial &&init, Tuple &&t, index_sequence< Is...>)
helper for fold_right_tuple: forwards tuple entries
auto fold_right(Reduce &&r, Initial &&init, Args &&...args)
Definition: fold_right.hpp:50
int value
Definition: gen_data.py:41
auto fold_right_tuple(Reduce &&r, Initial &&init, Tuple &&t)