sandbox
Loading...
Searching...
No Matches
concepts.hpp
1#ifndef LIBSBX_MATH_CONCEPTS_HPP_
2#define LIBSBX_MATH_CONCEPTS_HPP_
3
4#include <type_traits>
5#include <numbers>
6#include <limits>
7#include <cmath>
8
9namespace sbx::math {
10
11template<typename Type>
12concept numeric = (std::is_integral_v<Type> && !std::is_same_v<Type, bool>) || std::is_floating_point_v<Type>;
13
14
15
16template<typename Type>
17struct is_floating_point : std::bool_constant<std::is_floating_point_v<Type>> { };
18
19template<typename Type>
20inline constexpr bool is_floating_point_v = is_floating_point<Type>::value;
21
22template<typename Type>
23concept floating_point = is_floating_point_v<Type>;
24
25
26
27template<typename Type>
28struct is_integral : std::bool_constant<std::is_integral_v<Type> && !std::is_same_v<Type, bool>> { };
29
30template<typename Type>
31inline constexpr bool is_integral_v = is_integral<Type>::value;
32
33template<typename Type>
34concept integral = is_integral_v<Type>;
35
36template<typename Type>
37struct is_unsigned_integral : std::bool_constant<is_integral_v<Type> && std::is_unsigned_v<Type>> { };
38
39template<typename Type>
40inline constexpr bool is_unsigned_integral_v = is_unsigned_integral<Type>::value;
41
42template<typename Type>
43concept unsigned_integral = is_unsigned_integral_v<Type>;
44
45
46
47template<typename Type>
48struct is_scalar : std::bool_constant<is_floating_point_v<Type> || is_integral_v<Type>> { };
49
50template<typename Type>
51inline constexpr bool is_scalar_v = is_scalar<Type>::value;
52
53template<typename Type>
54concept scalar = is_scalar_v<Type>;
55
56} // namespace sbx::math
57
58#endif // LIBSBX_MATH_CONCEPTS_HPP_
Definition: concepts.hpp:17
Definition: concepts.hpp:28
Definition: concepts.hpp:48
Definition: concepts.hpp:37