The Gaudi Framework  master (37c0b60a)
detected.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 DETECTED_H
12 #define DETECTED_H
13 // implementation of Library Fundamentals TS V2 detected idiom,
14 // taken from http://en.cppreference.com/w/cpp/experimental/is_detected
15 // and http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4436.pdf
16 
17 #include <type_traits>
18 
19 namespace Gaudi::cpp17 {
20  namespace details {
21 
23  template <typename Default, typename AlwaysVoid, template <typename...> class Op, typename... Args>
24  struct detector {
25  constexpr static bool value = false;
26  using type = Default;
28  };
29 
31  template <typename Default, template <typename...> class Op, typename... Args>
32  struct detector<Default, std::void_t<Op<Args...>>, Op, Args...> {
33  constexpr static bool value = true;
34  using type = Op<Args...>;
36  };
37  } // namespace details
38 
39  template <template <class...> class Op, class... Args>
40  using is_detected = details::detector<void, void, Op, Args...>;
41 
42  template <template <class...> class Op, class... Args>
43  inline constexpr bool is_detected_v = is_detected<Op, Args...>::value;
44 
45  template <template <class...> class Op, class... Args>
46  using detected_t = typename is_detected<Op, Args...>::type;
47 
48  // Op<Args...> if that is a valid type, otherwise Default.
49  template <typename Default, template <typename...> class Op, typename... Args>
50  using detected_or_t = typename details::detector<Default, void, Op, Args...>::type;
51 
52 } // namespace Gaudi::cpp17
53 
54 #endif
std::false_type
Gaudi::cpp17
Definition: detected.h:19
Gaudi::cpp17::details::detector::value
constexpr static bool value
Definition: detected.h:25
details
Definition: AnyDataWrapper.h:19
Gaudi::cpp17::detected_or_t
typename details::detector< Default, void, Op, Args... >::type detected_or_t
Definition: detected.h:50
Gaudi::cpp17::details::detector< Default, std::void_t< Op< Args... > >, Op, Args... >::type
Op< Args... > type
Definition: detected.h:34
gaudirun.type
type
Definition: gaudirun.py:160
Gaudi::cpp17::detected_t
typename is_detected< Op, Args... >::type detected_t
Definition: detected.h:46
Gaudi::cpp17::details::detector
Implementation of the detection idiom (negative case).
Definition: detected.h:24
std
STL namespace.
Gaudi::cpp17::details::detector::type
Default type
Definition: detected.h:26
Gaudi::cpp17::is_detected_v
constexpr bool is_detected_v
Definition: detected.h:43
Gaudi::Utils::Histos::Formats::Default
@ Default
Definition: HistoTableFormat.h:96