Class default_arithmetic

Synopsis

#include <include/type_safe/arithmetic_policy.hpp>

class default_arithmetic

Description

An ArithmeticPolicy that behaves like the default integer implementations: Signed under/overflow is UB, unsigned under/overflow wraps around. \module types

Methods

do_addition
do_division
do_modulo
do_multiplication
do_subtraction

Source

Lines 21-53 in include/type_safe/arithmetic_policy.hpp.

class default_arithmetic
{
public:
    template <typename T>
    TYPE_SAFE_FORCE_INLINE static constexpr T do_addition(T a, T b) noexcept
    {
        return a + b;
    }

    template <typename T>
    TYPE_SAFE_FORCE_INLINE static constexpr T do_subtraction(T a, T b) noexcept
    {
        return a - b;
    }

    template <typename T>
    TYPE_SAFE_FORCE_INLINE static constexpr T do_multiplication(T a, T b) noexcept
    {
        return a * b;
    }

    template <typename T>
    TYPE_SAFE_FORCE_INLINE static constexpr T do_division(T a, T b) noexcept
    {
        return a / b;
    }

    template <typename T>
    TYPE_SAFE_FORCE_INLINE static constexpr T do_modulo(T a, T b) noexcept
    {
        return a % b;
    }
};





Add Discussion as Guest

Log in