Loading...
Searching...
No Matches
traits.hpp
1/*
2 * Copyright (c) 2022-2023, 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 <thrust/optional.h>
23
24#include <iterator>
25#include <optional>
26#include <type_traits>
27
28namespace cuspatial {
29
41#define CUSPATIAL_ENABLE_IF(...) typename std::enable_if_t<(__VA_ARGS__)>* = nullptr
42
47template <typename T, typename... Ts>
48constexpr bool is_same()
49{
50 return std::conjunction_v<std::is_same<T, Ts>...>;
51}
52
57template <typename U, typename... Ts>
58constexpr bool is_convertible_to()
59{
60 return std::conjunction_v<std::is_convertible<Ts, U>...>;
61}
62
67template <typename... Ts>
68constexpr bool is_floating_point()
69{
70 return std::conjunction_v<std::is_floating_point<Ts>...>;
71}
72
77template <typename... Ts>
78constexpr bool is_integral()
79{
80 return std::conjunction_v<std::is_integral<Ts>...>;
81}
82
83template <typename>
84constexpr bool is_vec_2d_impl = false;
85template <typename T>
86constexpr bool is_vec_2d_impl<vec_2d<T>> = true;
91template <typename T>
92constexpr bool is_vec_2d = is_vec_2d_impl<std::remove_cv_t<std::remove_reference_t<T>>>;
93
94template <typename>
95constexpr bool is_vec_3d_impl = false;
96template <typename T>
97constexpr bool is_vec_3d_impl<vec_3d<T>> = true;
102template <typename T>
103constexpr bool is_vec_3d = is_vec_3d_impl<std::remove_cv_t<std::remove_reference_t<T>>>;
104
109template <typename T, typename... Ts>
110constexpr bool is_same_floating_point()
111{
112 return std::conjunction_v<std::is_same<T, Ts>...> and
113 std::conjunction_v<std::is_floating_point<Ts>...>;
114}
115
116template <typename>
117constexpr bool is_optional_impl = false;
118template <typename T>
119constexpr bool is_optional_impl<std::optional<T>> = true;
124template <typename T>
125constexpr bool is_optional = is_optional_impl<std::remove_cv_t<std::remove_reference_t<T>>>;
126
133template <typename Iterator>
134using iterator_value_type = typename std::iterator_traits<Iterator>::value_type;
135
142template <typename Iterator>
143using iterator_vec_base_type = typename cuspatial::iterator_value_type<Iterator>::value_type;
144
145} // namespace cuspatial