24 #include <cuda/std/type_traits>
34 template <
typename...>
48 #define CUDF_ENABLE_IF(...) std::enable_if_t<(__VA_ARGS__)>* = nullptr
50 template <
typename L,
typename R>
51 using less_comparable = decltype(std::declval<L>() < std::declval<R>());
53 template <
typename L,
typename R>
54 using greater_comparable = decltype(std::declval<L>() > std::declval<R>());
56 template <
typename L,
typename R>
57 using equality_comparable = decltype(std::declval<L>() == std::declval<R>());
60 template <
typename L,
typename R,
typename =
void>
61 struct is_relationally_comparable_impl : std::false_type {
64 template <
typename L,
typename R>
65 struct is_relationally_comparable_impl<L,
67 void_t<less_comparable<L, R>, greater_comparable<L, R>>>
71 template <
typename L,
typename R,
typename =
void>
72 struct is_equality_comparable_impl : std::false_type {
75 template <
typename L,
typename R>
76 struct is_equality_comparable_impl<L, R, void_t<equality_comparable<L, R>>> : std::true_type {
80 template <
typename AlwaysVoid,
typename... Ts>
81 struct has_common_type_impl : std::false_type {
84 template <
typename... Ts>
85 struct has_common_type_impl<void_t<std::common_type_t<Ts...>>, Ts...> : std::true_type {
89 template <
typename... Ts>
90 using has_common_type =
typename detail::has_common_type_impl<void, Ts...>::type;
92 template <
typename... Ts>
93 constexpr
inline bool has_common_type_v = detail::has_common_type_impl<void, Ts...>::value;
96 using is_timestamp_t = cuda::std::disjunction<std::is_same<cudf::timestamp_D, T>,
97 std::is_same<cudf::timestamp_s, T>,
98 std::is_same<cudf::timestamp_ms, T>,
99 std::is_same<cudf::timestamp_us, T>,
100 std::is_same<cudf::timestamp_ns, T>>;
102 template <
typename T>
103 using is_duration_t = cuda::std::disjunction<std::is_same<cudf::duration_D, T>,
104 std::is_same<cudf::duration_s, T>,
105 std::is_same<cudf::duration_ms, T>,
106 std::is_same<cudf::duration_us, T>,
107 std::is_same<cudf::duration_ns, T>>;
121 template <
typename L,
typename R>
124 return detail::is_relationally_comparable_impl<L, R>::value;
132 template <
typename T>
133 inline bool operator()()
const
135 return cudf::is_relationally_comparable<T, T>();
164 template <
typename L,
typename R>
167 return detail::is_equality_comparable_impl<L, R>::value;
175 template <
typename T>
176 bool operator()()
const
178 return cudf::is_equality_comparable<T, T>();
202 template <
typename T>
205 return cuda::std::is_arithmetic<T>();
208 struct is_numeric_impl {
209 template <
typename T>
210 constexpr
bool operator()()
212 return is_numeric<T>();
243 template <
typename T>
246 return std::is_integral_v<T> and not std::is_same_v<T, bool>;
249 struct is_index_type_impl {
250 template <
typename T>
251 constexpr
bool operator()()
253 return is_index_type<T>();
280 template <
typename T>
283 return std::is_unsigned_v<T>;
286 struct is_unsigned_impl {
287 template <
typename T>
288 constexpr
bool operator()()
290 return is_unsigned<T>();
313 template <
typename Iterator>
316 return std::is_signed_v<typename std::iterator_traits<Iterator>::value_type>;
326 template <
typename T>
329 return std::is_floating_point_v<T>;
332 struct is_floating_point_impl {
333 template <
typename T>
334 constexpr
bool operator()()
336 return is_floating_point<T>();
361 template <
typename T>
364 return std::is_same_v<T, bool>;
367 struct is_boolean_impl {
368 template <
typename T>
369 constexpr
bool operator()()
371 return is_boolean<T>();
394 template <
typename T>
397 return is_timestamp_t<T>::value;
400 struct is_timestamp_impl {
401 template <
typename T>
402 constexpr
bool operator()()
404 return is_timestamp<T>();
429 template <
typename T>
432 return std::is_same_v<numeric::decimal32, T> || std::is_same_v<numeric::decimal64, T> ||
433 std::is_same_v<numeric::decimal128, T>;
436 struct is_fixed_point_impl {
437 template <
typename T>
438 constexpr
bool operator()()
440 return is_fixed_point<T>();
463 template <
typename T>
466 return is_duration_t<T>::value;
469 struct is_duration_impl {
470 template <
typename T>
471 constexpr
bool operator()()
473 return is_duration<T>();
498 template <
typename T>
501 return is_duration<T>() || is_timestamp<T>();
504 struct is_chrono_impl {
505 template <
typename T>
506 constexpr
bool operator()()
508 return is_chrono<T>();
538 template <
typename T>
541 return cudf::is_numeric<T>() or cudf::is_chrono<T>() or cudf::is_boolean<T>();
551 template <
typename T>
554 return std::is_same_v<dictionary32, T>;
557 struct is_dictionary_impl {
558 template <
typename T>
559 constexpr
bool operator()()
561 return is_dictionary<T>();
585 template <
typename T>
590 return cudf::is_numeric<T>() || cudf::is_chrono<T>() || cudf::is_fixed_point<T>();
593 struct is_fixed_width_impl {
594 template <
typename T>
595 constexpr
bool operator()()
597 return is_fixed_width<T>();
629 template <
typename T>
632 return std::is_same_v<T, cudf::string_view> or std::is_same_v<T, cudf::dictionary32> or
633 std::is_same_v<T, cudf::list_view> or std::is_same_v<T, cudf::struct_view>;
636 struct is_compound_impl {
637 template <
typename T>
638 constexpr
bool operator()()
640 return is_compound<T>();
672 template <
typename T>
675 return std::is_same_v<T, cudf::list_view> || std::is_same_v<T, cudf::struct_view>;
678 struct is_nested_impl {
679 template <
typename T>
680 constexpr
bool operator()()
682 return is_nested<T>();
708 template <
typename T>
711 return std::is_same_v<T, cudf::struct_view>;
714 struct is_struct_impl {
715 template <
typename T>
716 constexpr
bool operator()()
718 return is_struct<T>();
733 template <
typename FromType>
734 struct is_bit_castable_to_impl {
735 template <typename ToType, std::enable_if_t<is_compound<ToType>()>* =
nullptr>
736 constexpr
bool operator()()
741 template <typename ToType, std::enable_if_t<not is_compound<ToType>()>* =
nullptr>
742 constexpr
bool operator()()
744 if (not cuda::std::is_trivially_copyable_v<FromType> ||
745 not cuda::std::is_trivially_copyable_v<ToType>) {
750 return from_size == to_size;
754 struct is_bit_castable_from_impl {
755 template <typename FromType, std::enable_if_t<is_compound<FromType>()>* =
nullptr>
756 constexpr
bool operator()(data_type)
761 template <typename FromType, std::enable_if_t<not is_compound<FromType>()>* =
nullptr>
762 constexpr
bool operator()(data_type to)
786 template <
typename From,
typename To>
792 template <
typename Duration1,
typename Duration2>
794 : std::is_convertible<typename cudf::detail::time_point<Duration1>::duration,
795 typename cudf::detail::time_point<Duration2>::duration> {