Radium Engine  1.5.20
Loading...
Searching...
No Matches
StdExperimentalTypeTraits.hpp
1#pragma once
2
3/*
4 * This file provides
5 * - Ra::Core::Utils::is_detected, which is an alias for std::experimental::is_detected
6 * (see https://en.cppreference.com/w/cpp/experimental/is_detected) or which
7 * follows the sample implementation from
8 * https://en.cppreference.com/w/cpp/experimental/is_detected#Possible_implementation,
9 *
10 */
11
12#ifdef __has_include
13// cppcheck-suppress preprocessorErrorDirective
14# if __has_include( <experimental/type_traits> )
15# include <experimental/type_traits>
16# define have_experimental_type_traits
17# endif
18#endif
19
20namespace Ra {
21namespace Core {
22namespace Utils {
23#ifdef have_experimental_type_traits
24// use std::experimental definition
25template <template <class...> class Op, class... Args>
26using is_detected = typename std::experimental::is_detected<Op, Args...>;
27
28template <template <class...> class Op, class... Args>
29using detected_t = typename std::experimental::detected_t<Op, Args...>;
30
31template <class Default, template <class...> class Op, class... Args>
32using detected_or = typename std::experimental::detected_or<Default, Op, Args...>;
33
34#else
35// use possible implementation given in
36// https://en.cppreference.com/w/cpp/experimental/is_detected#Possible_implementation
37namespace detail {
38template <class Default, class AlwaysVoid, template <class...> class Op, class... Args>
39struct detector {
40 using value_t = std::false_type;
41 using type = Default;
42};
43
44template <class Default, template <class...> class Op, class... Args>
45struct detector<Default, std::void_t<Op<Args...>>, Op, Args...> {
46 using value_t = std::true_type;
47 using type = Op<Args...>;
48};
49} // namespace detail
50
51struct nonesuch {
52 ~nonesuch() = delete;
53 nonesuch( nonesuch const& ) = delete;
54 void operator=( nonesuch const& ) = delete;
55};
56
57template <template <class...> class Op, class... Args>
58using is_detected = typename detail::detector<nonesuch, void, Op, Args...>::value_t;
59
60template <template <class...> class Op, class... Args>
61using detected_t = typename detail::detector<nonesuch, void, Op, Args...>::type;
62
63template <class Default, template <class...> class Op, class... Args>
64using detected_or = detail::detector<Default, void, Op, Args...>;
65#endif
66} // namespace Utils
67} // namespace Core
68} // namespace Ra
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3
STL namespace.