tlx
Toggle main menu visibility
Loading...
Searching...
No Matches
call_foreach_tuple.hpp
Go to the documentation of this file.
1
/*******************************************************************************
2
* tlx/meta/call_foreach_tuple.hpp
3
*
4
* Part of tlx - http://panthema.net/tlx
5
*
6
* Copyright (C) 2016-2017 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_CALL_FOREACH_TUPLE_HEADER
12
#define TLX_META_CALL_FOREACH_TUPLE_HEADER
13
14
#include <tuple>
15
16
#include <
tlx/meta/call_foreach.hpp
>
17
#include <
tlx/meta/index_sequence.hpp
>
18
19
namespace
tlx
{
20
21
//! \addtogroup tlx_meta
22
//! \{
23
24
/******************************************************************************/
25
// Variadic Template Expander: run a generic templated functor (like a generic
26
// lambda) for each component of a std::tuple.
27
//
28
// Called with func(Argument arg).
29
30
namespace
meta_detail
{
31
32
//! helper for call_foreach_tuple
33
template
<
typename
Functor,
typename
Tuple, std::size_t... Is>
34
void
call_foreach_tuple_impl
(
35
Functor&& f, Tuple&& t,
index_sequence<Is...>
) {
36
return
call_foreach
(
37
std::forward<Functor>(f), std::get<Is>(std::forward<Tuple>(t)) ...);
38
}
39
40
}
// namespace meta_detail
41
42
//! Call a generic functor (like a generic lambda) to each components of a tuple
43
//! together with its zero-based index.
44
template
<
typename
Functor,
typename
Tuple>
45
void
call_foreach_tuple
(Functor&& f, Tuple&& t) {
46
using
Indices =
make_index_sequence
<
47
std::tuple_size<typename std::decay<Tuple>::type>::value>;
48
meta_detail::call_foreach_tuple_impl
(
49
std::forward<Functor>(f), std::forward<Tuple>(t), Indices());
50
}
51
52
//! \}
53
54
}
// namespace tlx
55
56
#endif
// !TLX_META_CALL_FOREACH_TUPLE_HEADER
57
58
/******************************************************************************/
call_foreach.hpp
tlx::call_foreach_tuple
void call_foreach_tuple(Functor &&f, Tuple &&t)
Call a generic functor (like a generic lambda) to each components of a tuple together with its zero-b...
Definition
call_foreach_tuple.hpp:45
tlx::call_foreach
void call_foreach(Functor &&f, Args &&... args)
Call a generic functor (like a generic lambda) for each variadic template argument.
Definition
call_foreach.hpp:47
index_sequence.hpp
tlx::meta_detail
Definition
apply_tuple.hpp:28
tlx::meta_detail::call_foreach_tuple_impl
void call_foreach_tuple_impl(Functor &&f, Tuple &&t, index_sequence< Is... >)
helper for call_foreach_tuple
Definition
call_foreach_tuple.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
tlx
meta
call_foreach_tuple.hpp
Generated on
for tlx by
1.17.0