template <typename T>

class CheckedNumeric

Defined at line 19 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

The following are helper templates used in the CheckedNumeric class.

Public Methods

void CheckedNumeric<T> ()

Defined at line 26 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

template <typename Src>
void CheckedNumeric<T> (const CheckedNumeric<Src> & rhs)

Copy constructor.

Defined at line 30 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

template <typename Src>
void CheckedNumeric<T> (Src value)

This is not an explicit constructor because we implicitly upgrade regular

numerics to CheckedNumerics to make them easier to use.

Defined at line 39 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

template <typename Src>
void CheckedNumeric<T> (StrictNumeric<Src> value)

This is not an explicit constructor because we want a seamless conversion

from StrictNumeric types.

Defined at line 47 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

template <typename Dst = T>
bool IsValid ()

IsValid() - The public API to test if a CheckedNumeric is currently valid.

A range checked destination type can be supplied using the Dst template

parameter.

Defined at line 55 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

template <typename Dst>
bool AssignIfValid (Dst * result)

Defined at line 65 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

template <typename Dst = T, class CheckHandler = CheckOnFailure>
StrictNumeric<Dst> ValueOrDie ()

ValueOrDie() - The primary accessor for the underlying value. If the

current state is not valid it will CHECK and crash.

A range checked destination type can be supplied using the Dst template

parameter, which will trigger a CHECK if the value is not in bounds for

the destination.

The CHECK behavior can be overridden by supplying a handler as a

template parameter, for test code, etc. However, the handler cannot access

the underlying value, and it is not available through other means.

Defined at line 85 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

template <typename Dst = T, typename Src>
StrictNumeric<Dst> ValueOrDefault (const Src default_value)

ValueOrDefault(T default_value) - A convenience method that returns the

current value if the state is valid, and the supplied default_value for

any other state.

A range checked destination type can be supplied using the Dst template

parameter. WARNING: This function may fail to compile or CHECK at runtime

if the supplied default_value is not within range of the destination type.

Defined at line 98 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

template <typename Dst>
CheckedNumeric<typename UnderlyingType<Dst>::type> Cast ()

Returns a checked numeric of the specified type, cast from the current

CheckedNumeric. If the current state is invalid or the destination cannot

represent the result then the returned CheckedNumeric will be invalid.

Defined at line 107 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

CheckedNumeric<T> operator- ()

Defined at line 139 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

CheckedNumeric<T> operator~ ()

Defined at line 154 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

CheckedNumeric<T> Abs ()

Defined at line 159 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

template <typename U>
CheckedNumeric<typename MathWrapper<CheckedMaxOp, T, U>::type> Max (const U rhs)

Defined at line 164 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

template <typename U>
CheckedNumeric<typename MathWrapper<CheckedMinOp, T, U>::type> Min (const U rhs)

Defined at line 179 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

CheckedNumeric<typename UnsignedOrFloatForSize<T>::type> UnsignedAbs ()

This function is available only for integral types. It returns an unsigned

integer of the same width as the source type, containing the absolute value

of the source, and properly handling signed min.

Defined at line 196 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

CheckedNumeric<T> & operator++ ()

Defined at line 202 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

CheckedNumeric<T> operator++ (int )

Defined at line 207 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

CheckedNumeric<T> & operator-- ()

Defined at line 213 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

CheckedNumeric<T> operator-- (int )

Defined at line 218 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

template <template <typename, typename, typename> class M, typename L, typename R>
CheckedNumeric<T> MathOp (const L lhs, const R rhs)

These perform the actual math operations on the CheckedNumerics.

Binary arithmetic operations.

Defined at line 229 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

template <template <typename, typename, typename> class M, typename R>
CheckedNumeric<T> & MathOp (const R rhs)

Assignment arithmetic operations.

Defined at line 240 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

template <typename Src>
CheckedNumeric<T> & operator+= (const Src rhs)

Assignment arithmetic operator implementation from CLASS##Numeric.

Defined at line 338 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

template <typename Src>
CheckedNumeric<T> & operator-= (const Src rhs)

Assignment arithmetic operator implementation from CLASS##Numeric.

Defined at line 339 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

template <typename Src>
CheckedNumeric<T> & operator*= (const Src rhs)

Assignment arithmetic operator implementation from CLASS##Numeric.

Defined at line 340 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

template <typename Src>
CheckedNumeric<T> & operator/= (const Src rhs)

Assignment arithmetic operator implementation from CLASS##Numeric.

Defined at line 341 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

template <typename Src>
CheckedNumeric<T> & operator%= (const Src rhs)

Assignment arithmetic operator implementation from CLASS##Numeric.

Defined at line 342 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

template <typename Src>
CheckedNumeric<T> & operator<<= (const Src rhs)

Assignment arithmetic operator implementation from CLASS##Numeric.

Defined at line 343 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

template <typename Src>
CheckedNumeric<T> & operator>>= (const Src rhs)

Assignment arithmetic operator implementation from CLASS##Numeric.

Defined at line 344 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

template <typename Src>
CheckedNumeric<T> & operator&= (const Src rhs)

Assignment arithmetic operator implementation from CLASS##Numeric.

Defined at line 345 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

template <typename Src>
CheckedNumeric<T> & operator|= (const Src rhs)

Assignment arithmetic operator implementation from CLASS##Numeric.

Defined at line 346 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

template <typename Src>
CheckedNumeric<T> & operator^= (const Src rhs)

Assignment arithmetic operator implementation from CLASS##Numeric.

Defined at line 347 of file ../../zircon/third_party/ulib/safemath/include/safemath/checked_math.h

Records

Friends

template <typename U>
U CheckedNumeric (const CheckedNumeric<U> & src)
template <typename Src>
class CheckedNumeric