Go to the documentation of this file. 1 #ifndef EAGINE_MATH_SIGN_HPP
9 #define EAGINE_MATH_SIGN_HPP
11 #include <type_traits>
29 constexpr
sign() noexcept = default;
32 constexpr explicit
sign(
bool pos) noexcept
38 typename = std::enable_if_t<!std::is_same_v<X, sign<T>>>>
39 constexpr
explicit sign(
const X& value) noexcept
40 : _positive{value >= X(0)} {}
45 typename = std::enable_if_t<!std::is_same_v<X, sign<T>>>>
47 _positive = (value >= X(0));
53 static constexpr
auto plus() noexcept ->
sign {
64 operator T() const noexcept {
65 return _positive ? T{1} : T{-1};
70 auto flip() noexcept -> auto& {
71 _positive = !_positive;
101 #endif // EAGINE_MATH_SIGN_HPP
auto operator-() const noexcept -> sign
Returns a new sign opposite to this sign.
Definition: sign.hpp:84
float value_type
Alias for the value type T.
Definition: sign.hpp:26
constexpr sign(const X &value) noexcept
Construction taking the sign from the specified numeric value.
Definition: sign.hpp:39
auto operator!() const noexcept -> sign
Returns a new sign opposite to this sign.
Definition: sign.hpp:91
Class representing a positive or negative numeric sign.
Definition: sign.hpp:20
Math-related code is placed in this namespace.
Definition: eagine.hpp:48
auto flipped() const noexcept -> sign
Returns a new sign opposite to this sign.
Definition: sign.hpp:77
constexpr sign() noexcept=default
Default constructor (constructs a positive sign).
static constexpr auto plus() noexcept -> sign
Constructs a positive sign (plus).
Definition: sign.hpp:53
auto flip() noexcept -> auto &
Flip this sign from positive to negative or vice-versa.
Definition: sign.hpp:70
auto operator=(const X &value) noexcept -> auto &
Assignment taking the sign from the specified numeric value.
Definition: sign.hpp:46
static constexpr auto minus() noexcept -> sign
Constructs a negative sign (minus).
Definition: sign.hpp:59