| The Gaudi Framework v32r1 (f65d50dc)

detected.h
Go to the documentation of this file.
1 #ifndef DETECTED_H
2 #define DETECTED_H
3 // implementation of Library Fundamentals TS V2 detected idiom,
4 // taken from http://en.cppreference.com/w/cpp/experimental/is_detected
5 // and http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4436.pdf
6
7 #include <type_traits>
8
9 namespace Gaudi::cpp17 {
10 namespace details {
11
13 template <typename Default, typename AlwaysVoid, template <typename...> class Op, typename... Args>
14 struct detector {
15 constexpr static bool value = false;
16 using type = Default;
17 using value_t = std::false_type;
18 };
19
21 template <typename Default, template <typename...> class Op, typename... Args>
22 struct detector<Default, std::void_t<Op<Args...>>, Op, Args...> {
23 constexpr static bool value = true;
24 using type = Op<Args...>;
25 using value_t = std::true_type;
26 };
27 } // namespace details
28
29 template <template <class...> class Op, class... Args>
30 using is_detected = details::detector<void, void, Op, Args...>;
31
32 template <template <class...> class Op, class... Args>
33 inline constexpr bool is_detected_v = is_detected<Op, Args...>::value;
34
35 template <template <class...> class Op, class... Args>
36 using detected_t = typename is_detected<Op, Args...>::type;
37
38 // Op<Args...> if that is a valid type, otherwise Default.
39 template <typename Default, template <typename...> class Op, typename... Args>
40 using detected_or_t = typename details::detector<Default, void, Op, Args...>::type;
41
42 } // namespace Gaudi::cpp17
43
44 #endif
Gaudi::cpp17::is_detected_v
constexpr bool is_detected_v
Definition: detected.h:33
Gaudi::cpp17
Definition: detected.h:9
Gaudi::cpp17::detected_t
typename is_detected< Op, Args... >::type detected_t
Definition: detected.h:36
std
STL namespace.
details
Definition: AnyDataWrapper.h:10
gaudirun.type
type
Definition: gaudirun.py:142
Gaudi::cpp17::details::detector
Implementation of the detection idiom (negative case).
Definition: detected.h:14
Gaudi::Utils::Histos::Formats::Default
Definition: HistoTableFormat.h:86
std::false_type
Gaudi::cpp17::details::detector::type
Default type
Definition: detected.h:16
Gaudi::cpp17::details::detector< Default, std::void_t< Op< Args... > >, Op, Args... >::type
Op< Args... > type
Definition: detected.h:24
Gaudi::cpp17::details::detector::value
static constexpr bool value
Definition: detected.h:15
Gaudi::cpp17::detected_or_t
typename details::detector< Default, void, Op, Args... >::type detected_or_t
Definition: detected.h:40