Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:37

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 DETECTED_H
0012 #define DETECTED_H
0013 // implementation of Library Fundamentals TS V2 detected idiom,
0014 // taken from http://en.cppreference.com/w/cpp/experimental/is_detected
0015 // and http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4436.pdf
0016 
0017 #include <type_traits>
0018 
0019 namespace Gaudi::cpp17 {
0020   namespace details {
0021 
0022     /// Implementation of the detection idiom (negative case).
0023     template <typename Default, typename AlwaysVoid, template <typename...> class Op, typename... Args>
0024     struct detector {
0025       constexpr static bool value = false;
0026       using type                  = Default;
0027       using value_t               = std::false_type;
0028     };
0029 
0030     /// Implementation of the detection idiom (positive case).
0031     template <typename Default, template <typename...> class Op, typename... Args>
0032     struct detector<Default, std::void_t<Op<Args...>>, Op, Args...> {
0033       constexpr static bool value = true;
0034       using type                  = Op<Args...>;
0035       using value_t               = std::true_type;
0036     };
0037   } // namespace details
0038 
0039   template <template <class...> class Op, class... Args>
0040   using is_detected = details::detector<void, void, Op, Args...>;
0041 
0042   template <template <class...> class Op, class... Args>
0043   inline constexpr bool is_detected_v = is_detected<Op, Args...>::value;
0044 
0045   template <template <class...> class Op, class... Args>
0046   using detected_t = typename is_detected<Op, Args...>::type;
0047 
0048   // Op<Args...> if that is a valid type, otherwise Default.
0049   template <typename Default, template <typename...> class Op, typename... Args>
0050   using detected_or_t = typename details::detector<Default, void, Op, Args...>::type;
0051 
0052 } // namespace Gaudi::cpp17
0053 
0054 #endif