PLSSVM - Parallel Least Squares Support Vector Machine  2.0.0
A Least Squares Support Vector Machine implementation using different backends.
type_traits.hpp
Go to the documentation of this file.
1 
12 #ifndef PLSSVM_DETAIL_TYPE_TRAITS_HPP_
13 #define PLSSVM_DETAIL_TYPE_TRAITS_HPP_
14 #pragma once
15 
16 #include <array> // std::array
17 #include <deque> // std::deque
18 #include <forward_list> // std::forward_list
19 #include <list> // std::list
20 #include <map> // std::map, std::multimap
21 #include <set> // std::set, std::multiset
22 #include <type_traits> // std::remove_cv_t, std::remove_reference_t, std::false_type, std::true_type
23 #include <type_traits> // std::enable_if_t
24 #include <unordered_map> // std::unordered_map, std::unordered_multimap
25 #include <unordered_set> // std::unordered_set, std::unordered_multiset
26 #include <vector> // std:.vector
27 
28 namespace plssvm::detail {
29 
33 #define PLSSVM_REQUIRES(...) std::enable_if_t<__VA_ARGS__, bool> = true
34 
38 template <typename>
39 constexpr bool always_false_v = false;
40 
45 template <typename T>
46 using remove_cvref_t = std::remove_cv_t<std::remove_reference_t<T>>;
47 
52 template <typename T>
53 struct is_array : std::false_type {};
57 template <typename T, std::size_t I>
58 struct is_array<std::array<T, I>> : std::true_type {};
62 template <typename T>
63 constexpr bool is_array_v = is_array<T>::value;
64 
69 template <typename T>
70 struct is_vector : std::false_type {};
74 template <typename T>
75 struct is_vector<std::vector<T>> : std::true_type {};
79 template <typename T>
81 
86 template <typename T>
87 struct is_deque : std::false_type {};
91 template <typename T>
92 struct is_deque<std::deque<T>> : std::true_type {};
96 template <typename T>
97 constexpr bool is_deque_v = is_deque<T>::value;
98 
103 template <typename T>
104 struct is_forward_list : std::false_type {};
108 template <typename T>
109 struct is_forward_list<std::forward_list<T>> : std::true_type {};
113 template <typename T>
115 
120 template <typename T>
121 struct is_list : std::false_type {};
125 template <typename T>
126 struct is_list<std::list<T>> : std::true_type {};
130 template <typename T>
131 constexpr bool is_list_v = is_list<T>::value;
132 
136 template <typename T>
137 constexpr bool is_sequence_container_v = is_array_v<T> || is_vector_v<T> || is_deque_v<T> || is_forward_list_v<T> || is_list_v<T>;
138 
143 template <typename T>
144 struct is_set : std::false_type {};
148 template <typename T>
149 struct is_set<std::set<T>> : std::true_type {};
153 template <typename T>
154 constexpr bool is_set_v = is_set<T>::value;
155 
160 template <typename T>
161 struct is_map : std::false_type {};
165 template <typename Key, typename T>
166 struct is_map<std::map<Key, T>> : std::true_type {};
170 template <typename T>
171 constexpr bool is_map_v = is_map<T>::value;
172 
177 template <typename T>
178 struct is_multiset : std::false_type {};
182 template <typename T>
183 struct is_multiset<std::multiset<T>> : std::true_type {};
187 template <typename T>
189 
194 template <typename T>
195 struct is_multimap : std::false_type {};
199 template <typename Key, typename T>
200 struct is_multimap<std::multimap<Key, T>> : std::true_type {};
204 template <typename T>
206 
210 template <typename T>
211 constexpr bool is_associative_container_v = is_set_v<T> || is_map_v<T> || is_multimap_v<T> || is_multiset_v<T>;
212 
217 template <typename T>
218 struct is_unordered_set : std::false_type {};
222 template <typename T>
223 struct is_unordered_set<std::unordered_set<T>> : std::true_type {};
227 template <typename T>
229 
234 template <typename T>
235 struct is_unordered_map : std::false_type {};
239 template <typename Key, typename T>
240 struct is_unordered_map<std::unordered_map<Key, T>> : std::true_type {};
244 template <typename T>
246 
251 template <typename T>
252 struct is_unordered_multiset : std::false_type {};
256 template <typename T>
257 struct is_unordered_multiset<std::unordered_multiset<T>> : std::true_type {};
261 template <typename T>
263 
268 template <typename T>
269 struct is_unordered_multimap : std::false_type {};
273 template <typename Key, typename T>
274 struct is_unordered_multimap<std::unordered_multimap<Key, T>> : std::true_type {};
278 template <typename T>
280 
284 template <typename T>
285 constexpr bool is_unordered_associative_container_v = is_unordered_set_v<T> || is_unordered_map_v<T> || is_unordered_multimap_v<T> || is_unordered_multiset_v<T>;
286 
290 template <typename T>
291 constexpr bool is_container_v = is_sequence_container_v<T> || is_associative_container_v<T> || is_unordered_associative_container_v<T>;
292 
293 } // namespace plssvm::detail
294 
295 #endif // PLSSVM_DETAIL_TYPE_TRAITS_HPP_
Namespace containing implementation details. Should not directly be used by users.
Definition: csvm.hpp:27
constexpr bool is_map_v
Type trait to check whether T is a std::map.
Definition: type_traits.hpp:171
constexpr bool is_container_v
Type trait to check whether T is a container.
Definition: type_traits.hpp:291
constexpr bool is_unordered_multiset_v
Type trait to check whether T is a std::unordered_multiset.
Definition: type_traits.hpp:262
constexpr bool is_set_v
Type trait to check whether T is a std::set.
Definition: type_traits.hpp:154
std::remove_cv_t< std::remove_reference_t< T > > remove_cvref_t
Remove the topmost reference- and cv-qualifiers.
Definition: type_traits.hpp:46
constexpr bool is_unordered_multimap_v
Type trait to check whether T is a std::unordered_multimap.
Definition: type_traits.hpp:279
constexpr bool is_unordered_associative_container_v
Type trait to check whether T is a unordered associative container.
Definition: type_traits.hpp:285
constexpr bool is_vector_v
Type trait to check whether T is a std::vector.
Definition: type_traits.hpp:80
constexpr bool is_forward_list_v
Type trait to check whether T is a std::forward_list.
Definition: type_traits.hpp:114
constexpr bool is_multimap_v
Type trait to check whether T is a std::multimap.
Definition: type_traits.hpp:205
constexpr bool is_unordered_map_v
Type trait to check whether T is a std::unordered_map.
Definition: type_traits.hpp:245
constexpr bool always_false_v
Type-dependent expression that always evaluates to false.
Definition: type_traits.hpp:39
constexpr bool is_array_v
Type trait to check whether T is a std::array.
Definition: type_traits.hpp:63
constexpr bool is_deque_v
Type trait to check whether T is a std::deque.
Definition: type_traits.hpp:97
constexpr bool is_sequence_container_v
Type trait to check whether T is a sequence container.
Definition: type_traits.hpp:137
constexpr bool is_list_v
Type trait to check whether T is a std::list.
Definition: type_traits.hpp:131
constexpr bool is_unordered_set_v
Type trait to check whether T is a std::unordered_set.
Definition: type_traits.hpp:228
constexpr bool is_associative_container_v
Type trait to check whether T is a associative container.
Definition: type_traits.hpp:211
constexpr bool is_multiset_v
Type trait to check whether T is a std::multiset.
Definition: type_traits.hpp:188
Type trait to check whether T is a std::array.
Definition: type_traits.hpp:53
Type trait to check whether T is a std::deque.
Definition: type_traits.hpp:87
Type trait to check whether T is a std::forward_list.
Definition: type_traits.hpp:104
Type trait to check whether T is a std::list.
Definition: type_traits.hpp:121
Type trait to check whether T is a std::map.
Definition: type_traits.hpp:161
Type trait to check whether T is a std::multimap.
Definition: type_traits.hpp:195
Type trait to check whether T is a std::multiset.
Definition: type_traits.hpp:178
Type trait to check whether T is a std::set.
Definition: type_traits.hpp:144
Type trait to check whether T is a std::unordered_map.
Definition: type_traits.hpp:235
Type trait to check whether T is a std::unordered_multimap.
Definition: type_traits.hpp:269
Type trait to check whether T is a std::unordered_multiset.
Definition: type_traits.hpp:252
Type trait to check whether T is a std::unordered_set.
Definition: type_traits.hpp:218
Type trait to check whether T is a std::vector.
Definition: type_traits.hpp:70