The Gaudi Framework  master (37c0b60a)
compose.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIKERNEL_COMPOSE_H
12 #define GAUDIKERNEL_COMPOSE_H
13 
14 #include <utility> // std::forward, std::move (objects)
15 
16 namespace Gaudi {
17 
18  namespace details {
19 
20  // C++17 version: https://godbolt.org/g/YdcvGg
21  template <typename... lambda_ts>
22  struct overloaded_t : lambda_ts... {
23  using lambda_ts::operator()...;
24  };
25  template <typename... lambda_ts>
26  overloaded_t( lambda_ts... ) -> overloaded_t<lambda_ts...>;
27 
28  } // namespace details
29 
30  //
31  // Create an object with an overloaded call operator by 'composing'/'joining'
32  // a set of callables (such as lambdas)
33  //
34  // see eg. the example at http://en.cppreference.com/w/cpp/utility/variant/visit
35  // for an example of why this is usefull
36  //
37  template <typename... lambda_ts>
38  auto overload( lambda_ts&&... lambdas ) {
39  return details::overloaded_t{ std::forward<lambda_ts>( lambdas )... };
40  }
41 } // namespace Gaudi
42 
43 // for backwards compatibility
44 // [[deprecated("please use Gaudi::overload instead of compose")]]
45 template <typename... lambda_ts>
46 auto compose( lambda_ts&&... lambdas ) {
47  return Gaudi::overload( std::forward<lambda_ts>( lambdas )... );
48 }
49 
50 #endif
details
Definition: AnyDataWrapper.h:19
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
Gaudi::details::overloaded_t
Definition: compose.h:22
compose
auto compose(lambda_ts &&... lambdas)
Definition: compose.h:46
Gaudi::details::overloaded_t
overloaded_t(lambda_ts...) -> overloaded_t< lambda_ts... >
Gaudi::overload
auto overload(lambda_ts &&... lambdas)
Definition: compose.h:38