tlx
Toggle main menu visibility
Loading...
Searching...
No Matches
vmap_foreach_tuple.hpp
Go to the documentation of this file.
1
/*******************************************************************************
2
* tlx/meta/vmap_foreach_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_VMAP_FOREACH_TUPLE_HEADER
12
#define TLX_META_VMAP_FOREACH_TUPLE_HEADER
13
14
#include <
tlx/meta/index_sequence.hpp
>
15
#include <
tlx/meta/vmap_foreach.hpp
>
16
#include <tuple>
17
18
namespace
tlx
{
19
20
//! \addtogroup tlx_meta
21
//! \{
22
23
/******************************************************************************/
24
// Variadic Template Expander: run a generic templated functor (like a generic
25
// lambda) for each component of a tuple, and collect the returned values in a
26
// generic std::tuple.
27
28
namespace
meta_detail
{
29
30
//! helper for vmap_foreach_tuple: forwards tuple entries
31
template
<
typename
Functor,
typename
Tuple, std::size_t... Is>
32
auto
vmap_foreach_tuple_impl
(
33
Functor&& f, Tuple&& t,
index_sequence<Is...>
) {
34
return
vmap_foreach
(std::forward<Functor>(f),
35
std::get<Is>(std::forward<Tuple>(t)) ...);
36
}
37
38
}
// namespace meta_detail
39
40
//! Call a generic functor (like a generic lambda) for each variadic template
41
//! argument and collect the result in a std::tuple<>.
42
template
<
typename
Functor,
typename
Tuple>
43
auto
vmap_foreach_tuple
(Functor&& f, Tuple&& t) {
44
using
Indices =
make_index_sequence
<
45
std::tuple_size<typename std::decay<Tuple>::type>::value>;
46
return
meta_detail::vmap_foreach_tuple_impl
(
47
std::forward<Functor>(f), std::forward<Tuple>(t), Indices());
48
}
49
50
//! \}
51
52
}
// namespace tlx
53
54
#endif
// !TLX_META_VMAP_FOREACH_TUPLE_HEADER
55
56
/******************************************************************************/
tlx::vmap_foreach
auto vmap_foreach(Functor &&f, Args &&... args)
Call a generic functor (like a generic lambda) for each variadic template argument.
Definition
vmap_foreach.hpp:51
tlx::vmap_foreach_tuple
auto vmap_foreach_tuple(Functor &&f, Tuple &&t)
Call a generic functor (like a generic lambda) for each variadic template argument and collect the re...
Definition
vmap_foreach_tuple.hpp:43
index_sequence.hpp
tlx::meta_detail
Definition
apply_tuple.hpp:28
tlx::meta_detail::vmap_foreach_tuple_impl
auto vmap_foreach_tuple_impl(Functor &&f, Tuple &&t, index_sequence< Is... >)
helper for vmap_foreach_tuple: forwards tuple entries
Definition
vmap_foreach_tuple.hpp:32
tlx
Definition
exclusive_scan.hpp:17
tlx::index_sequence
Definition
index_sequence.hpp:25
tlx::make_index_sequence
Definition
index_sequence.hpp:49
vmap_foreach.hpp
tlx
meta
vmap_foreach_tuple.hpp
Generated on
for tlx by
1.17.0