PLSSVM - Parallel Least Squares Support Vector Machine  2.0.0
A Least Squares Support Vector Machine implementation using different backends.
type_list.hpp
Go to the documentation of this file.
1 
12 #ifndef PLSSVM_DETAIL_TYPE_LIST_MANIPULATION_HPP_
13 #define PLSSVM_DETAIL_TYPE_LIST_MANIPULATION_HPP_
14 #pragma once
15 
16 #include <string> // std::string
17 #include <tuple> // std::tuple
18 #include <type_traits> // std::disjunction, std::is_same_v
19 
20 namespace plssvm::detail {
21 
27 template <typename T, typename U>
29  using real_type = T;
30  using label_type = U;
31 };
32 
33 // concatenate the types of two tuples in a new tuple
34 template <typename S, typename T>
41 template <typename... FirstTupleTypes, typename... SecondTupleTypes>
42 struct concat_tuple_types<std::tuple<FirstTupleTypes...>, std::tuple<SecondTupleTypes...>> {
43  using type = std::tuple<FirstTupleTypes..., SecondTupleTypes...>;
44 };
48 template <typename... T>
49 using concat_tuple_types_t = typename concat_tuple_types<T...>::type;
50 
51 // calculate the cartesian product of the types in two tuples and return a new tuple with the corresponding real_type_label_type_combination types.
52 template <typename S, typename T>
60 template <typename FirstTupleType, typename... FirstTupleRemainingTypes, typename... SecondTupleTypes>
61 struct cartesian_type_product<std::tuple<FirstTupleType, FirstTupleRemainingTypes...>, std::tuple<SecondTupleTypes...>> {
62  // the cartesian product of {FirstTupleType} and {SecondTupleTypes...} is a list of real_type_label_type_combination
63  using FirstTupleType_cross_SecondTupleTypes = std::tuple<real_type_label_type_combination<FirstTupleType, SecondTupleTypes>...>;
64 
65  // the cartesian product of {FirstTupleRemainingTypes...} and {Ts...} (computed recursively)
66  using FirstTupleRemainingTypes_cross_SecondTupleTypes = typename cartesian_type_product<std::tuple<FirstTupleRemainingTypes...>, std::tuple<SecondTupleTypes...>>::type;
67 
68  // concatenate both products
70 };
71 // end the recursion if the first tuple does not have any types left
72 template <typename... SecondTupleTypes>
73 struct cartesian_type_product<std::tuple<>, std::tuple<SecondTupleTypes...>> {
74  using type = std::tuple<>; // the cartesian product of {}x{...} is {}
75 };
79 template <typename... T>
80 using cartesian_type_product_t = typename cartesian_type_product<T...>::type;
81 
83 using real_type_list = std::tuple<float, double>;
84 
86 using label_type_list = std::tuple<bool, char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double, long double, std::string>;
87 
90 
97 template <typename T, typename Tuple>
99 
105 template <typename T, typename... Types>
106 struct type_list_contains<T, std::tuple<Types...>> : std::disjunction<std::is_same<T, Types>...> {};
107 
111 template <typename T, typename Tuple>
113 
114 } // namespace plssvm::detail
115 
116 #endif // PLSSVM_DETAIL_TYPE_LIST_MANIPULATION_HPP_
Namespace containing implementation details. Should not directly be used by users.
Definition: csvm.hpp:27
detail::cartesian_type_product_t< real_type_list, label_type_list > real_type_label_type_combination_list
The cartesian product of all real types and label types as std::tuple.
Definition: type_list.hpp:89
typename cartesian_type_product< T... >::type cartesian_type_product_t
Shorthand for the typename cartesian_type_product<...>::type type.
Definition: type_list.hpp:80
std::tuple< bool, char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double, long double, std::string > label_type_list
A type list of all supported label types (currently arithmetic types and std::string) as std::tuple.
Definition: type_list.hpp:86
typename concat_tuple_types< T... >::type concat_tuple_types_t
Shorthand for the typename concat_tuple_types<...>::type type.
Definition: type_list.hpp:49
std::tuple< float, double > real_type_list
A type list of all supported real types as std::tuple.
Definition: type_list.hpp:83
constexpr bool type_list_contains_v
Checks whether the type T is present in the Tuple.
Definition: type_list.hpp:112
Definition: type_list.hpp:53
Definition: type_list.hpp:35
Encapsulates a combination of a used real_type (float or double) and label_type (an arithmetic type o...
Definition: type_list.hpp:28
Checks whether the type T is present in the Tuple.
Definition: type_list.hpp:98