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