knncolle
Collection of KNN methods in C++
Loading...
Searching...
No Matches
NumericType.hpp
Go to the documentation of this file.
1#ifndef KNNCOLLE_NUMERIC_TYPE_HPP
2#define KNNCOLLE_NUMERIC_TYPE_HPP
3
4#include <cstddef>
5#include <cstdint>
6#include <type_traits>
7
13namespace knncolle {
14
18enum class NumericType : char {
19 UINT8_T, INT8_T,
20 UINT16_T, INT16_T,
21 UINT32_T, INT32_T,
22 UINT64_T, INT64_T,
23 UNSIGNED_CHAR, SIGNED_CHAR, CHAR,
24 UNSIGNED_SHORT, SHORT,
25 UNSIGNED_INT, INT,
26 UNSIGNED_LONG, LONG,
27 UNSIGNED_LONG_LONG, LONG_LONG,
28 SIZE_T, PTRDIFF_T,
29 FLOAT, DOUBLE,
30 UNKNOWN
31};
32
42template<typename Type_>
44#ifdef UINT8_MAX
45 if constexpr(std::is_same<Type_, std::uint8_t>::value) {
46 return NumericType::UINT8_T;
47 }
48#endif
49#ifdef INT8_MAX
50 if constexpr(std::is_same<Type_, std::int8_t>::value) {
51 return NumericType::INT8_T;
52 }
53#endif
54
55#ifdef UINT16_MAX
56 if constexpr(std::is_same<Type_, std::uint16_t>::value) {
57 return NumericType::UINT16_T;
58 }
59#endif
60#ifdef INT16_MAX
61 if constexpr(std::is_same<Type_, std::int16_t>::value) {
62 return NumericType::INT16_T;
63 }
64#endif
65
66#ifdef UINT32_MAX
67 if constexpr(std::is_same<Type_, std::uint32_t>::value) {
68 return NumericType::UINT32_T;
69 }
70#endif
71#ifdef INT32_MAX
72 if constexpr(std::is_same<Type_, std::int32_t>::value) {
73 return NumericType::INT32_T;
74 }
75#endif
76
77#ifdef UINT64_MAX
78 if constexpr(std::is_same<Type_, std::uint64_t>::value) {
79 return NumericType::UINT64_T;
80 }
81#endif
82#ifdef INT64_MAX
83 if constexpr(std::is_same<Type_, std::int64_t>::value) {
84 return NumericType::INT64_T;
85 }
86#endif
87
88 if constexpr(std::is_same<Type_, unsigned char>::value) {
89 return NumericType::UNSIGNED_CHAR;
90 }
91 if constexpr(std::is_same<Type_, signed char>::value) {
92 return NumericType::SIGNED_CHAR;
93 }
94 if constexpr(std::is_same<Type_, char>::value) {
95 return NumericType::CHAR;
96 }
97
98 if constexpr(std::is_same<Type_, unsigned short>::value) {
99 return NumericType::UNSIGNED_SHORT;
100 }
101 if constexpr(std::is_same<Type_, short>::value) {
102 return NumericType::SHORT;
103 }
104
105 if constexpr(std::is_same<Type_, unsigned int>::value) {
106 return NumericType::UNSIGNED_INT;
107 }
108 if constexpr(std::is_same<Type_, int>::value) {
109 return NumericType::INT;
110 }
111
112 if constexpr(std::is_same<Type_, unsigned long>::value) {
113 return NumericType::UNSIGNED_LONG;
114 }
115 if constexpr(std::is_same<Type_, long>::value) {
116 return NumericType::LONG;
117 }
118
119 if constexpr(std::is_same<Type_, unsigned long long>::value) {
120 return NumericType::UNSIGNED_LONG_LONG;
121 }
122 if constexpr(std::is_same<Type_, long long>::value) {
123 return NumericType::LONG_LONG;
124 }
125
126 if constexpr(std::is_same<Type_, std::size_t>::value) {
127 return NumericType::SIZE_T;
128 }
129 if constexpr(std::is_same<Type_, std::ptrdiff_t>::value) {
130 return NumericType::PTRDIFF_T;
131 }
132
133 if constexpr(std::is_same<Type_, float>::value) {
134 return NumericType::FLOAT;
135 }
136 if constexpr(std::is_same<Type_, double>::value) {
137 return NumericType::DOUBLE;
138 }
139
140 return NumericType::UNKNOWN;
141}
142
143}
144
145#endif
Collection of KNN algorithms.
Definition Bruteforce.hpp:28
NumericType get_numeric_type()
Definition NumericType.hpp:43
NumericType
Definition NumericType.hpp:18