Argon 0.1.0
Loading...
Searching...
No Matches
helpers.hpp
Go to the documentation of this file.
1#pragma once
2#include <type_traits>
3#include "../arm_simd.hpp"
4#include "features.h"
5
10
12namespace argon::helpers {
13// clang-format off
14
17template <typename T>
18constexpr bool has_smaller_v =
19 std::is_same_v<T, uint16_t>
20 || std::is_same_v<T, uint32_t>
21 || std::is_same_v<T, uint64_t>
22 || std::is_same_v<T, int16_t>
23 || std::is_same_v<T, int32_t>
24 || std::is_same_v<T, int64_t>
25 || std::is_same_v<T, double>
26#if ARGON_HAS_HALF_FLOAT
27 || std::is_same_v<T, float>
28 || std::is_same_v<T, float32_t>
29#endif
30 ;
31
34template <typename T>
35constexpr bool has_larger_v =
36 std::is_same_v<T, uint8_t>
37 || std::is_same_v<T, uint16_t>
38 || std::is_same_v<T, uint32_t>
39 || std::is_same_v<T, int8_t>
40 || std::is_same_v<T, int16_t>
41 || std::is_same_v<T, int32_t>
42 || std::is_same_v<T, float>
43#if ARGON_HAS_HALF_FLOAT
44 || std::is_same_v<T, float16_t>
45#endif
46 ;
47
49template <typename T>
51
53template <typename T>
55
58template <typename T> struct NextLarger;
60template <> struct NextLarger<int8_t> { using type = int16_t; };
61template <> struct NextLarger<uint8_t> { using type = uint16_t; };
62template <> struct NextLarger<int16_t> { using type = int32_t; };
63template <> struct NextLarger<uint16_t> { using type = uint32_t; };
64template <> struct NextLarger<int32_t> { using type = int64_t; };
65template <> struct NextLarger<uint32_t> { using type = uint64_t; };
66template <> struct NextLarger<float> { using type = double; };
67#if ARGON_HAS_HALF_FLOAT
68template <> struct NextLarger<float16_t> { using type = float; };
69#endif
71
74template <typename T>
76
79template <typename T> struct NextSmaller;
80
82template <> struct NextSmaller<int16_t> { using type = int8_t; };
83template <> struct NextSmaller<uint16_t> { using type = uint8_t; };
84template <> struct NextSmaller<int32_t> { using type = int16_t; };
85template <> struct NextSmaller<uint32_t> { using type = uint16_t; };
86template <> struct NextSmaller<int64_t> { using type = int32_t; };
87template <> struct NextSmaller<uint64_t> { using type = uint32_t; };
88template <> struct NextSmaller<double> { using type = float; };
89#if ARGON_HAS_HALF_FLOAT
90template <> struct NextSmaller<float> { using type = float16_t; };
91#endif
93
96template <typename T>
98
99// clang-format on
100} // namespace argon::helpers
Definition helpers.hpp:54
Concept to check if a type has a smaller corresponding type.
Definition helpers.hpp:50
Header file for SIMD features and platform detection.
Contains helper templates and concepts for type manipulation and compile-time utilities.
Definition helpers.hpp:12
constexpr bool has_larger_v
Helper template to determine if a type has a larger corresponding type.
Definition helpers.hpp:35
NextSmaller< T >::type NextSmaller_t
Helper alias to get the next smaller type for a given type.
Definition helpers.hpp:97
constexpr bool has_smaller_v
Helper template to determine if a type has a smaller corresponding type.
Definition helpers.hpp:18
NextLarger< T >::type NextLarger_t
Helper alias to get the next larger type for a given type.
Definition helpers.hpp:75
Helper template to determine the next larger type for a given type.
Definition helpers.hpp:58
Helper template to determine the next smaller type for a given type.
Definition helpers.hpp:79