加载中...
搜索中...
无匹配项
traits.hpp
1/*
2 * 版权所有 (c) 2022-2025, NVIDIA CORPORATION。
3 *
4 * 根据 Apache 许可证 2.0 版本(“许可证”)获得许可;
5 * 除非符合许可证,否则不得使用此文件。
6 * 您可以在以下位置获取许可证副本:
7 *
8 * https://apache.ac.cn/licenses/LICENSE-2.0
9 *
10 * 除非适用法律要求或书面同意,否则根据许可证分发的软件
11 * 按“原样”分发,不附带任何明示或暗示的保证或条件。
12 * 有关管理权限和
13 * 限制的特定语言,请参阅许可证。
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} // 命名空间 cuspatial