modm API documentation
modm::Saturated< T > Class Template Reference

Saturation arithmetic building on 'Integer-Overflow-Builtins' Implementation works with integer, unsigned integer and float or reference to them. Operators work with the same types or Saturated types of them. More...

#include <modm/math/saturation/saturated.hpp>

Public Member Functions

constexpr Saturated (const T &value)
 
constexpr Saturated (const Saturated< T > &other)
 
template<typename U >
requires constexpr std::integral< std::remove_reference_t< U > > Saturated (const U &v)
 
template<typename U >
requires constexpr std::floating_point< std::remove_reference_t< U > > Saturated (const U &v)
 
template<typename U >
requires constexpr std::integral< std::remove_reference_t< U > > Saturated (const Saturated< U > &other)
 
TP getValue () const
 
 operator T & ()
 
 operator T () const
 
constexpr auto operator<=> (const Saturated< T > &) const = default
 
void operator= (const Saturated &other)
 
template<typename U >
requires std::integral< std::remove_reference_t< U > > void operator= (const Saturated< U > &other)
 
Saturated & operator++ ()
 
Saturated & operator-- ()
 
Saturated operator++ (int)
 
Saturated operator-- (int)
 
template<typename U >
requires std::unsigned_integral< std::remove_reference_t< U > > Saturated & operator+= (const Saturated< U > &other)
 
template<typename U >
requires std::signed_integral< std::remove_reference_t< U > > Saturated & operator+= (const Saturated< U > &other)
 
template<typename U >
requires std::unsigned_integral< std::remove_reference_t< U > > Saturated & operator-= (const Saturated< U > &other)
 
template<typename U >
requires std::signed_integral< std::remove_reference_t< U > > Saturated & operator-= (const Saturated< U > &other)
 
template<typename U >
requires std::unsigned_integral< std::remove_reference_t< U > > Saturated & operator*= (const Saturated< U > &other)
 
template<typename U >
requires std::signed_integral< std::remove_reference_t< U > > Saturated & operator*= (const Saturated< U > &other)
 
template<typename U >
requires std::unsigned_integral< std::remove_reference_t< U > > Saturated & operator*= (const U &v)
 
template<typename U >
requires std::signed_integral< std::remove_reference_t< U > > Saturated & operator*= (const U &v)
 
template<typename U >
requires std::unsigned_integral< std::remove_reference_t< U > > TP operator+ (const Saturated< U > &other)
 
template<typename U >
requires std::signed_integral< std::remove_reference_t< U > > TP operator+ (const Saturated< U > &other)
 
template<typename U >
requires std::unsigned_integral< std::remove_reference_t< U > > TP operator- (const Saturated< U > &other)
 
template<typename U >
requires std::signed_integral< std::remove_reference_t< U > > TP operator- (const Saturated< U > &other)
 
TP operator* (const Saturated< T > &other)
 
TS operator- ()
 
void absolute ()
 

Protected Typedefs

using TP = std::remove_reference_t< T >
 
using TS = std::conditional_t< std::is_signed_v< T >, T, std::make_signed_t< modm::WideType< TP > >>
 

Protected Attributes

value = 0
 

Detailed Description

template<typename T>
class modm::Saturated< T >

Saturation arithmetic building on 'Integer-Overflow-Builtins' Implementation works with integer, unsigned integer and float or reference to them. Operators work with the same types or Saturated types of them.

See also
https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html
https://en.wikipedia.org/wiki/Saturation_arithmetic
Author
Thomas Sommer

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