MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
Loading...
Searching...
No Matches
mtl::detail::sat_traits< T > Struct Template Reference

The integer types saturating_cast clamps: the integral types, and __int128 / unsigned __int128 where the compiler has them. More...

#include <projection.hpp>

Static Public Member Functions

static constexpr T min () noexcept
static constexpr T max () noexcept

Static Public Attributes

static constexpr bool is_int = std::is_integral_v<T>
static constexpr bool is_signed = std::numeric_limits<T>::is_signed

Detailed Description

template<typename T>
struct mtl::detail::sat_traits< T >

The integer types saturating_cast clamps: the integral types, and __int128 / unsigned __int128 where the compiler has them.

Under strict -std=c++20 (MTL5's own build) std::is_integral is false for those, so a cast from __int128 skipped the clamp and truncated (issue 865). Their signedness and limits are given here too: with MSVC's standard library (clang-cl) std::numeric_limits is not specialized for them, so is_signed was false and min() and max() were 0 (#871, Windows Clang-CL).

Member Function Documentation

◆ max()

template<typename T>
constexpr T mtl::detail::sat_traits< T >::max ( )
inlinestaticconstexprnoexcept

◆ min()

template<typename T>
constexpr T mtl::detail::sat_traits< T >::min ( )
inlinestaticconstexprnoexcept

Member Data Documentation

◆ is_int

template<typename T>
bool mtl::detail::sat_traits< T >::is_int = std::is_integral_v<T>
staticconstexpr

◆ is_signed

template<typename T>
bool mtl::detail::sat_traits< T >::is_signed = std::numeric_limits<T>::is_signed
staticconstexpr

The documentation for this struct was generated from the following file: