Skyward boardcore
Loading...
Searching...
No Matches
detail Namespace Reference

Functions

template<class T >
auto add_sat (T x, T y) noexcept -> typename std::enable_if_t< std::is_integral< T >::value, T >
 Computes the saturating addition x + y for integral types.
 
template<typename To , typename From >
auto bit_cast (const From &src) noexcept -> typename std::enable_if_t< sizeof(To)==sizeof(From) &&std::is_trivially_copyable< To >::value &&std::is_trivially_copyable< From >::value, To >
 Obtain a value of type To by reinterpreting the object representation of From.
 

Function Documentation

◆ add_sat()

template<class T >
auto detail::add_sat ( x,
y 
) -> typename std::enable_if_t<std::is_integral<T>::value, T>
noexcept

Computes the saturating addition x + y for integral types.

Returns
x + y, if the result is representable as a value of type T. Otherwise, the largest or smallest value of type T, whichever is closer to the result.

Definition at line 43 of file Numeric.h.

◆ bit_cast()

template<typename To , typename From >
auto detail::bit_cast ( const From &  src) -> typename std::enable_if_t<sizeof(To) == sizeof(From) && std::is_trivially_copyable<To>::value && std::is_trivially_copyable<From>::value, To>
noexcept

Obtain a value of type To by reinterpreting the object representation of From.

This implementation is a polyfill for C++20's std::bit_cast.

Returns
A new object of type To with the same bit representation as src.

Definition at line 68 of file Numeric.h.