The Gaudi Framework  v32r2 (46d42edc)
compose.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_COMPOSE_H
2 #define GAUDIKERNEL_COMPOSE_H
3 
4 #include <utility> // std::forward, std::move (objects)
5 
6 namespace Gaudi {
7 
8  namespace details {
9 
10  // C++17 version: https://godbolt.org/g/YdcvGg
11  template <typename... lambda_ts>
12  struct overloaded_t : lambda_ts... {
13  using lambda_ts::operator()...;
14  };
15  template <typename... lambda_ts>
16  overloaded_t( lambda_ts... )->overloaded_t<lambda_ts...>;
17 
18  } // namespace details
19 
20  //
21  // Create an object with an overloaded call operator by 'composing'/'joining'
22  // a set of callables (such as lambdas)
23  //
24  // see eg. the example at http://en.cppreference.com/w/cpp/utility/variant/visit
25  // for an example of why this is usefull
26  //
27  template <typename... lambda_ts>
28  auto overload( lambda_ts&&... lambdas ) {
29  return details::overloaded_t{std::forward<lambda_ts>( lambdas )...};
30  }
31 } // namespace Gaudi
32 
33 // for backwards compatibility
34 // [[deprecated("please use Gaudi::overload instead of compose")]]
35 template <typename... lambda_ts>
36 auto compose( lambda_ts&&... lambdas ) {
37  return Gaudi::overload( std::forward<lambda_ts>( lambdas )... );
38 }
39 
40 #endif
auto compose(lambda_ts &&... lambdas)
Definition: compose.h:36
overloaded_t(lambda_ts...) -> overloaded_t< lambda_ts... >
auto overload(lambda_ts &&... lambdas)
Definition: compose.h:28
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1