tlx
Toggle main menu visibility
Loading...
Searching...
No Matches
vmap_foreach_tuple_with_index.hpp
Go to the documentation of this file.
1
/*******************************************************************************
2
* tlx/meta/vmap_foreach_tuple_with_index.hpp
3
*
4
* Part of tlx - http://panthema.net/tlx
5
*
6
* Copyright (C) 2018 Timo Bingmann <tb@panthema.net>
7
*
8
* All rights reserved. Published under the Boost Software License, Version 1.0
9
******************************************************************************/
10
11
#ifndef TLX_META_VMAP_FOREACH_TUPLE_WITH_INDEX_HEADER
12
#define TLX_META_VMAP_FOREACH_TUPLE_WITH_INDEX_HEADER
13
14
#include <
tlx/meta/index_sequence.hpp
>
15
#include <
tlx/meta/vmap_foreach_with_index.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
// Called with func(StaticIndex<> index, Argument arg).
29
30
namespace
meta_detail
{
31
32
//! helper for vmap_foreach_tuple_with_index: forwards tuple entries
33
template
<
typename
Functor,
typename
Tuple, std::size_t... Is>
34
auto
vmap_foreach_tuple_with_index_impl
(
35
Functor&& f, Tuple&& t,
index_sequence<Is...>
) {
36
return
vmap_foreach_with_index
(std::forward<Functor>(f),
37
std::get<Is>(std::forward<Tuple>(t)) ...);
38
}
39
40
}
// namespace meta_detail
41
42
//! Call a generic functor (like a generic lambda) for each variadic template
43
//! argument and collect the result in a std::tuple<>.
44
template
<
typename
Functor,
typename
Tuple>
45
auto
vmap_foreach_tuple_with_index
(Functor&& f, Tuple&& t) {
46
using
Indices =
make_index_sequence
<
47
std::tuple_size<typename std::decay<Tuple>::type>::value>;
48
return
meta_detail::vmap_foreach_tuple_with_index_impl
(
49
std::forward<Functor>(f), std::forward<Tuple>(t), Indices());
50
}
51
52
//! \}
53
54
}
// namespace tlx
55
56
#endif
// !TLX_META_VMAP_FOREACH_TUPLE_WITH_INDEX_HEADER
57
58
/******************************************************************************/
tlx::vmap_foreach_tuple_with_index
auto vmap_foreach_tuple_with_index(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_with_index.hpp:45
tlx::vmap_foreach_with_index
auto vmap_foreach_with_index(Functor &&f, Args &&... args)
Call a generic functor (like a generic lambda) for each variadic template argument together with its ...
Definition
vmap_foreach_with_index.hpp:56
index_sequence.hpp
tlx::meta_detail
Definition
apply_tuple.hpp:28
tlx::meta_detail::vmap_foreach_tuple_with_index_impl
auto vmap_foreach_tuple_with_index_impl(Functor &&f, Tuple &&t, index_sequence< Is... >)
helper for vmap_foreach_tuple_with_index: forwards tuple entries
Definition
vmap_foreach_tuple_with_index.hpp:34
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_with_index.hpp
tlx
meta
vmap_foreach_tuple_with_index.hpp
Generated on
for tlx by
1.17.0