| The Gaudi Framework v30r0 (c919700c)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

compose.h
Go to the documentation of this file.
1
2
3 namespace details
4 {
5
6 #if __cplusplus > 201402L
7
8 // C++17 version: https://godbolt.org/g/2vAZQt
9 template <typename... lambda_ts>
10 struct composer_t : lambda_ts... {
11 template <typename... T>
12 composer_t( T&&... t ) : lambda_ts( std::forward<T>( t ) )...
13 {
14 }
15
16 using lambda_ts::operator()...;
17 };
18
19 #else
20
21 template <typename... lambda_ts>
22 struct composer_t;
23
24 template <typename lambda_t>
25 struct composer_t<lambda_t> : lambda_t {
26 composer_t( const lambda_t& lambda ) : lambda_t{lambda} {}
27 composer_t( lambda_t&& lambda ) : lambda_t{std::move( lambda )} {}
28
29 using lambda_t::operator();
30 };
31
32 template <typename lambda_t, typename... more_lambda_ts>
33 struct composer_t<lambda_t, more_lambda_ts...> : lambda_t, composer_t<more_lambda_ts...> {
34 using super_t = composer_t<more_lambda_ts...>;
35
36 template <typename... lambda_ts>
37 composer_t( const lambda_t& lambda, lambda_ts&&... more_lambdas )
38 : lambda_t{lambda}, super_t{std::forward<lambda_ts>( more_lambdas )...}
39 {
40 }
41 template <typename... lambda_ts>
42 composer_t( lambda_t&& lambda, lambda_ts&&... more_lambdas )
43 : lambda_t{std::move( lambda )}, super_t{std::forward<lambda_ts>( more_lambdas )...}
44 {
45 }
46
47 using lambda_t::operator();
48 using super_t::operator();
49 };
50 #endif
51 }
52
53 template <typename... lambda_ts>
54 details::composer_t<std::decay_t<lambda_ts>...> compose( lambda_ts&&... lambdas )
55 {
56 return {std::forward<lambda_ts>( lambdas )...};
57 }
details::composer_t< lambda_t >::composer_t
composer_t(lambda_t &&lambda)
Definition: compose.h:27
details::composer_t
Definition: compose.h:22
details
Definition: compose.h:3
std::move
T move(T...args)
details::composer_t< lambda_t, more_lambda_ts... >::composer_t
composer_t(lambda_t &&lambda, lambda_ts &&...more_lambdas)
Definition: compose.h:42
compose
details::composer_t< std::decay_t< lambda_ts >... > compose(lambda_ts &&...lambdas)
Definition: compose.h:54
details::composer_t< lambda_t >::composer_t
composer_t(const lambda_t &lambda)
Definition: compose.h:26
details::composer_t< lambda_t, more_lambda_ts... >::composer_t
composer_t(const lambda_t &lambda, lambda_ts &&...more_lambdas)
Definition: compose.h:37