Loading...
Searching...
No Matches
traits.hpp
1/*
2 * Copyright (c) 2022-2025, NVIDIA CORPORATION.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
20#include <cuspatial/geometry/vec_3d.hpp>
21
22#include <iterator>
23#include <optional>
24#include <type_traits>
25
26namespace cuspatial {
27
39#define CUSPATIAL_ENABLE_IF(...) typename std::enable_if_t<(__VA_ARGS__)>* = nullptr
40
45template <typename T, typename... Ts>
46constexpr bool is_same()
47{
48 return std::conjunction_v<std::is_same<T, Ts>...>;
49}
50
55template <typename U, typename... Ts>
56constexpr bool is_convertible_to()
57{
58 return std::conjunction_v<std::is_convertible<Ts, U>...>;
59}
60
65template <typename... Ts>
66constexpr bool is_floating_point()
67{
68 return std::conjunction_v<std::is_floating_point<Ts>...>;
69}
70
75template <typename... Ts>
76constexpr bool is_integral()
77{
78 return std::conjunction_v<std::is_integral<Ts>...>;
79}
80
81template <typename>
82constexpr bool is_vec_2d_impl = false;
83template <typename T>
84constexpr bool is_vec_2d_impl<vec_2d<T>> = true;
89template <typename T>
90constexpr bool is_vec_2d = is_vec_2d_impl<std::remove_cv_t<std::remove_reference_t<T>>>;
91
92template <typename>
93constexpr bool is_vec_3d_impl = false;
94template <typename T>
95constexpr bool is_vec_3d_impl<vec_3d<T>> = true;
100template <typename T>
101constexpr bool is_vec_3d = is_vec_3d_impl<std::remove_cv_t<std::remove_reference_t<T>>>;
102
107template <typename T, typename... Ts>
108constexpr bool is_same_floating_point()
109{
110 return std::conjunction_v<std::is_same<T, Ts>...> and
111 std::conjunction_v<std::is_floating_point<Ts>...>;
112}
113
114template <typename>
115constexpr bool is_optional_impl = false;
116template <typename T>
117constexpr bool is_optional_impl<std::optional<T>> = true;
122template <typename T>
123constexpr bool is_optional = is_optional_impl<std::remove_cv_t<std::remove_reference_t<T>>>;
124
131template <typename Iterator>
132using iterator_value_type = typename std::iterator_traits<Iterator>::value_type;
133
140template <typename Iterator>
141using iterator_vec_base_type = typename cuspatial::iterator_value_type<Iterator>::value_type;
142
143} // namespace cuspatial