sandbox
Loading...
Searching...
No Matches
traits.hpp
1// SPDX-License-Identifier: MIT
2#ifndef LIBSBX_MATH_TRAITS_HPP_
3#define LIBSBX_MATH_TRAITS_HPP_
4
7
8namespace sbx::math {
9
10template<typename>
12
13template<integral Type>
14struct comparision_traits<Type> {
15
16 template<scalar Other>
17 inline static constexpr auto equal(Type lhs, Other rhs) noexcept -> bool {
18 return lhs == static_cast<Type>(rhs);
19 }
20
21}; // template<integral Type>
22
23template<floating_point Type>
24struct comparision_traits<Type> {
25
26 template<scalar Other>
27 inline static constexpr auto equal(Type lhs, Other rhs) noexcept -> bool {
28 return std::abs(lhs - static_cast<Type>(rhs)) <= epsilon_v<Type>;
29 }
30
31}; // template<floating_point Type>
32
33} // namespace sbx::math
34
35#endif // LIBSBX_MATH_TRAITS_HPP_
Mathematical constants.
Core numeric concepts and type traits.
Definition: traits.hpp:11