Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  master (d98a2936)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
detected.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 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 #pragma once
12 // implementation of Library Fundamentals TS V2 detected idiom,
13 // taken from http://en.cppreference.com/w/cpp/experimental/is_detected
14 // and http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4436.pdf
15 
16 #include <type_traits>
17 
18 namespace Gaudi::cpp17 {
19  namespace details {
20 
22  template <typename Default, typename AlwaysVoid, template <typename...> class Op, typename... Args>
23  struct detector {
24  constexpr static bool value = false;
25  using type = Default;
26  using value_t = std::false_type;
27  };
28 
30  template <typename Default, template <typename...> class Op, typename... Args>
31  struct detector<Default, std::void_t<Op<Args...>>, Op, Args...> {
32  constexpr static bool value = true;
33  using type = Op<Args...>;
34  using value_t = std::true_type;
35  };
36  } // namespace details
37 
38  template <template <class...> class Op, class... Args>
39  using is_detected = details::detector<void, void, Op, Args...>;
40 
41  template <template <class...> class Op, class... Args>
42  inline constexpr bool is_detected_v = is_detected<Op, Args...>::value;
43 
44  template <template <class...> class Op, class... Args>
45  using detected_t = typename is_detected<Op, Args...>::type;
46 
47  // Op<Args...> if that is a valid type, otherwise Default.
48  template <typename Default, template <typename...> class Op, typename... Args>
49  using detected_or_t = typename details::detector<Default, void, Op, Args...>::type;
50 
51 } // namespace Gaudi::cpp17
Gaudi::cpp17::details::detector< Default, std::void_t< Op< Args... > >, Op, Args... >::value_t
std::true_type value_t
Definition: detected.h:34
Gaudi::cpp17
Definition: detected.h:18
GaudiPartProp.decorators.std
std
Definition: decorators.py:32
Gaudi::cpp17::details::detector::value
constexpr static bool value
Definition: detected.h:24
details
Definition: AnyDataWrapper.h:19
Gaudi::cpp17::details::detector::value_t
std::false_type value_t
Definition: detected.h:26
Gaudi::cpp17::detected_or_t
typename details::detector< Default, void, Op, Args... >::type detected_or_t
Definition: detected.h:49
Gaudi::cpp17::details::detector< Default, std::void_t< Op< Args... > >, Op, Args... >::type
Op< Args... > type
Definition: detected.h:33
gaudirun.type
type
Definition: gaudirun.py:160
Gaudi::cpp17::detected_t
typename is_detected< Op, Args... >::type detected_t
Definition: detected.h:45
Gaudi::cpp17::details::detector
Implementation of the detection idiom (negative case).
Definition: detected.h:23
Gaudi::cpp17::details::detector::type
Default type
Definition: detected.h:25
Gaudi::cpp17::is_detected_v
constexpr bool is_detected_v
Definition: detected.h:42
Gaudi::Utils::Histos::Formats::Default
@ Default
Definition: HistoTableFormat.h:95