tlx
Toggle main menu visibility
Loading...
Searching...
No Matches
fold_left_tuple.hpp
Go to the documentation of this file.
1
/*******************************************************************************
2
* tlx/meta/fold_left_tuple.hpp
3
*
4
* Part of tlx - http://panthema.net/tlx
5
*
6
* Copyright (C) 2018 Hung Tran <hung@ae.cs.uni-frankfurt.de>
7
*
8
* All rights reserved. Published under the Boost Software License, Version 1.0
9
******************************************************************************/
10
11
#ifndef TLX_META_FOLD_LEFT_TUPLE_HEADER
12
#define TLX_META_FOLD_LEFT_TUPLE_HEADER
13
14
#include <
tlx/meta/fold_left.hpp
>
15
#include <
tlx/meta/index_sequence.hpp
>
16
#include <tuple>
17
18
namespace
tlx
{
19
20
//! \addtogroup tlx_meta
21
//! \{
22
23
/******************************************************************************/
24
// Variadic Template Expander: Implements fold_left() on the components of a
25
// tuple.
26
27
namespace
meta_detail
{
28
29
//! helper for fold_left_tuple: forwards tuple entries
30
template
<
typename
Reduce,
typename
Initial,
typename
Tuple, std::size_t... Is>
31
auto
fold_left_tuple_impl
(Reduce&& r, Initial&& init, Tuple&& t,
32
index_sequence<Is...>
) {
33
return
fold_left
(
34
std::forward<Reduce>(r), std::forward<Initial>(init),
35
std::get<Is>(std::forward<Tuple>(t)) ...);
36
}
37
38
}
// namespace meta_detail
39
40
//! Implements fold_left() -- ((a * b) * c) -- with a binary Reduce operation
41
//! and initial value on a tuple.
42
template
<
typename
Reduce,
typename
Initial,
typename
Tuple>
43
auto
fold_left_tuple
(Reduce&& r, Initial&& init, Tuple&& t) {
44
using
Indices =
make_index_sequence
<
45
std::tuple_size<typename std::decay<Tuple>::type>::value>;
46
return
meta_detail::fold_left_tuple_impl
(
47
std::forward<Reduce>(r), std::forward<Initial>(init),
48
std::forward<Tuple>(t), Indices());
49
}
50
51
//! \}
52
53
}
// namespace tlx
54
55
#endif
// !TLX_META_FOLD_LEFT_TUPLE_HEADER
56
57
/******************************************************************************/
fold_left.hpp
tlx::fold_left_tuple
auto fold_left_tuple(Reduce &&r, Initial &&init, Tuple &&t)
Implements fold_left() – ((a * b) * c) – with a binary Reduce operation and initial value on a tuple.
Definition
fold_left_tuple.hpp:43
tlx::fold_left
auto fold_left(Reduce &&r, Initial &&init, Args &&... args)
Implements fold_left() – ((a * b) * c) – with a binary Reduce operation and initial value.
Definition
fold_left.hpp:51
index_sequence.hpp
tlx::meta_detail
Definition
apply_tuple.hpp:28
tlx::meta_detail::fold_left_tuple_impl
auto fold_left_tuple_impl(Reduce &&r, Initial &&init, Tuple &&t, index_sequence< Is... >)
helper for fold_left_tuple: forwards tuple entries
Definition
fold_left_tuple.hpp:31
tlx
Definition
exclusive_scan.hpp:17
tlx::index_sequence
Definition
index_sequence.hpp:25
tlx::make_index_sequence
Definition
index_sequence.hpp:49
tlx
meta
fold_left_tuple.hpp
Generated on
for tlx by
1.17.0