|
||||
File indexing completed on 2025-01-18 09:57:36
0001 /***********************************************************************************\ 0002 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations * 0003 * * 0004 * This software is distributed under the terms of the Apache version 2 licence, * 0005 * copied verbatim in the file "LICENSE". * 0006 * * 0007 * In applying this licence, CERN does not waive the privileges and immunities * 0008 * granted to it by virtue of its status as an Intergovernmental Organization * 0009 * or submit itself to any jurisdiction. * 0010 \***********************************************************************************/ 0011 #ifndef GAUDIKERNEL_COMPOSE_H 0012 #define GAUDIKERNEL_COMPOSE_H 0013 0014 #include <utility> // std::forward, std::move (objects) 0015 0016 namespace Gaudi { 0017 0018 namespace details { 0019 0020 // C++17 version: https://godbolt.org/g/YdcvGg 0021 template <typename... lambda_ts> 0022 struct overloaded_t : lambda_ts... { 0023 using lambda_ts::operator()...; 0024 }; 0025 template <typename... lambda_ts> 0026 overloaded_t( lambda_ts... ) -> overloaded_t<lambda_ts...>; 0027 0028 } // namespace details 0029 0030 // 0031 // Create an object with an overloaded call operator by 'composing'/'joining' 0032 // a set of callables (such as lambdas) 0033 // 0034 // see eg. the example at http://en.cppreference.com/w/cpp/utility/variant/visit 0035 // for an example of why this is usefull 0036 // 0037 template <typename... lambda_ts> 0038 auto overload( lambda_ts&&... lambdas ) { 0039 return details::overloaded_t{ std::forward<lambda_ts>( lambdas )... }; 0040 } 0041 } // namespace Gaudi 0042 0043 // for backwards compatibility 0044 // [[deprecated("please use Gaudi::overload instead of compose")]] 0045 template <typename... lambda_ts> 0046 auto compose( lambda_ts&&... lambdas ) { 0047 return Gaudi::overload( std::forward<lambda_ts>( lambdas )... ); 0048 } 0049 0050 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |