16 #ifndef KOKKOS_DETECTION_IDIOM_HPP
17 #define KOKKOS_DETECTION_IDIOM_HPP
18 #ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
19 #define KOKKOS_IMPL_PUBLIC_INCLUDE
20 #define KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_DETECTIONIDIOM
23 #include <Kokkos_Macros.hpp>
26 #include <type_traits>
38 struct nonesuch_base {};
41 template <
class Default,
class ,
template <
class...>
class Op,
44 using value_t = std::false_type;
49 template <
class Default,
template <
class...>
class Op,
class... Args>
50 struct detector<Default, std::void_t<Op<Args...>>, Op, Args...> {
51 using value_t = std::true_type;
52 using type = Op<Args...>;
56 struct nonesuch :
private Impl::nonesuch_base {
58 nonesuch(nonesuch
const&) =
delete;
59 void operator=(nonesuch
const&) =
delete;
62 template <
template <
class...>
class Op,
class... Args>
64 typename Impl::detector<nonesuch, void, Op, Args...>::value_t;
66 template <
template <
class...>
class Op,
class... Args>
67 using detected_t =
typename Impl::detector<nonesuch, void, Op, Args...>::type;
69 template <
class Default,
template <
class...>
class Op,
class... Args>
70 using detected_or_t =
typename Impl::detector<Default, void, Op, Args...>::type;
72 template <
class Expected,
template <
class...>
class Op,
class... Args>
73 using is_detected_exact = std::is_same<Expected, detected_t<Op, Args...>>;
75 template <
class To,
template <
class...>
class Op,
class... Args>
76 using is_detected_convertible =
77 std::is_convertible<detected_t<Op, Args...>, To>;
79 template <
template <
class...>
class Op,
class... Args>
80 inline constexpr
bool is_detected_v = is_detected<Op, Args...>::value;
82 template <
class Expected,
template <
class...>
class Op,
class... Args>
83 inline constexpr
bool is_detected_exact_v =
84 is_detected_exact<Expected, Op, Args...>::value;
86 template <
class Expected,
template <
class...>
class Op,
class... Args>
87 inline constexpr
bool is_detected_convertible_v =
88 is_detected_convertible<Expected, Op, Args...>::value;
92 #ifdef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_DETECTIONIDIOM
93 #undef KOKKOS_IMPL_PUBLIC_INCLUDE
94 #undef KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_DETECTIONIDIOM