sandbox
Loading...
Searching...
No Matches
concepts.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
26#ifndef LIBSBX_MATH_CONCEPTS_HPP_
27#define LIBSBX_MATH_CONCEPTS_HPP_
28
29#include <type_traits>
30#include <numbers>
31#include <limits>
32#include <cmath>
33
34namespace sbx::math {
35
47template<typename Type>
48concept numeric = (std::is_integral_v<Type> && !std::is_same_v<Type, bool>) || std::is_floating_point_v<Type>;
49
55template<typename Type>
56struct is_floating_point : std::bool_constant<std::is_floating_point_v<Type>> { };
57
63template<typename Type>
65
71template<typename Type>
72concept floating_point = is_floating_point_v<Type>;
73
79template<typename Type>
80struct is_integral : std::bool_constant<std::is_integral_v<Type> && !std::is_same_v<Type, bool>> { };
81
87template<typename Type>
89
95template<typename Type>
96concept integral = is_integral_v<Type>;
97
103template<typename Type>
104struct is_unsigned_integral : std::bool_constant<is_integral_v<Type> && std::is_unsigned_v<Type>> { };
105
111template<typename Type>
113
119template<typename Type>
120concept unsigned_integral = is_unsigned_integral_v<Type>;
121
133template<typename Type>
134struct is_scalar : std::bool_constant<is_floating_point_v<Type> || is_integral_v<Type>> { };
135
141template<typename Type>
142inline constexpr bool is_scalar_v = is_scalar<Type>::value;
143
149template<typename Type>
150concept scalar = is_scalar_v<Type>;
151
152} // namespace sbx::math
153
154#endif // LIBSBX_MATH_CONCEPTS_HPP_
Concept for floating-point types.
Definition: concepts.hpp:72
Concept for non-boolean integral types.
Definition: concepts.hpp:96
Concept for numeric types.
Definition: concepts.hpp:48
Concept for scalar numeric types.
Definition: concepts.hpp:150
Concept for unsigned integral types.
Definition: concepts.hpp:120
constexpr bool is_floating_point_v
Convenience variable for is_floating_point.
Definition: concepts.hpp:64
constexpr bool is_integral_v
Convenience variable for is_integral.
Definition: concepts.hpp:88
constexpr bool is_unsigned_integral_v
Convenience variable for is_unsigned_integral.
Definition: concepts.hpp:112
constexpr bool is_scalar_v
Convenience variable for is_scalar.
Definition: concepts.hpp:142
Type trait identifying floating-point types.
Definition: concepts.hpp:56
Type trait identifying non-boolean integral types.
Definition: concepts.hpp:80
Type trait identifying scalar types.
Definition: concepts.hpp:134
Type trait identifying unsigned integral types.
Definition: concepts.hpp:104