xte::sign_cast()

Defined in header <xte/math/sign_cast.hpp>

Casts an integer or floating-point to the signedness of the destination integer type before converting the value.


Definition

template<xte::is_int T>
constexpr auto sign_cast = [][[nodiscard]](xte::is_number auto x) static noexcept -> T { /* ... */ };



Example

static_assert(xte::sign_cast<unsigned long long>(-1) == UINT_MAX);
[View in Compiler Explorer]