tlx
Loading...
Searching...
No Matches
call_foreach.hpp
Go to the documentation of this file.
1
/*******************************************************************************
2
* tlx/meta/call_foreach.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_HEADER
12
#define TLX_META_CALL_FOREACH_HEADER
13
14
#include <utility>
15
16
namespace
tlx
{
17
18
//! \addtogroup tlx_meta
19
//! \{
20
21
/******************************************************************************/
22
// Variadic Template Expander: run a generic templated functor (like a generic
23
// lambda) for each of the variadic template parameters.
24
25
namespace
meta_detail {
26
27
//! helper for call_foreach: base case
28
template
<
typename
Functor,
typename
Arg>
29
void
call_foreach_impl
(Functor&& f, Arg&& arg) {
30
std::forward<Functor>(f)(std::forward<Arg>(arg));
31
}
32
33
//! helper for call_foreach: general recursive case
34
template
<
typename
Functor,
typename
Arg,
typename
... MoreArgs>
35
void
call_foreach_impl
(
36
Functor&& f, Arg&& arg, MoreArgs&& ... rest) {
37
std::forward<Functor>(f)(std::forward<Arg>(arg));
38
call_foreach_impl
(
39
std::forward<Functor>(f), std::forward<MoreArgs>(rest) ...);
40
}
41
42
}
// namespace meta_detail
43
44
//! Call a generic functor (like a generic lambda) for each variadic template
45
//! argument.
46
template
<
typename
Functor,
typename
... Args>
47
void
call_foreach
(Functor&& f, Args&& ... args) {
48
meta_detail::call_foreach_impl
(
49
std::forward<Functor>(f), std::forward<Args>(args) ...);
50
}
51
52
//! \}
53
54
}
// namespace tlx
55
56
#endif
// !TLX_META_CALL_FOREACH_HEADER
57
58
/******************************************************************************/
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
tlx::meta_detail::call_foreach_impl
void call_foreach_impl(Functor &&f, Arg &&arg)
helper for call_foreach: base case
Definition
call_foreach.hpp:29
tlx
Definition
exclusive_scan.hpp:17
tlx
meta
call_foreach.hpp
Generated on Sat Jul 20 2024 00:00:00 for tlx by
1.12.0