template <typename T>

class CheckedNumeric

Defined at line 19 of file ../../third_party/mini_chromium/src/base/numerics/checked_math.h

The following are helper templates used in the CheckedNumeric class.

Public Methods

void CheckedNumeric<T> ()

Defined at line 26 of file ../../third_party/mini_chromium/src/base/numerics/checked_math.h

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

Copy constructor.

Defined at line 30 of file ../../third_party/mini_chromium/src/base/numerics/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 ../../third_party/mini_chromium/src/base/numerics/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 ../../third_party/mini_chromium/src/base/numerics/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 ../../third_party/mini_chromium/src/base/numerics/checked_math.h

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

AssignIfValid(Dst) - Assigns the underlying value if it is currently valid

and is within the range supported by the destination type. Returns true if

successful and false otherwise.

Defined at line 64 of file ../../third_party/mini_chromium/src/base/numerics/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 79 of file ../../third_party/mini_chromium/src/base/numerics/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 92 of file ../../third_party/mini_chromium/src/base/numerics/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 102 of file ../../third_party/mini_chromium/src/base/numerics/checked_math.h

CheckedNumeric<T> operator- ()

Defined at line 134 of file ../../third_party/mini_chromium/src/base/numerics/checked_math.h

CheckedNumeric<T> operator~ ()

Defined at line 149 of file ../../third_party/mini_chromium/src/base/numerics/checked_math.h

CheckedNumeric<T> Abs ()

Defined at line 154 of file ../../third_party/mini_chromium/src/base/numerics/checked_math.h

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

Defined at line 159 of file ../../third_party/mini_chromium/src/base/numerics/checked_math.h

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

Defined at line 174 of file ../../third_party/mini_chromium/src/base/numerics/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 191 of file ../../third_party/mini_chromium/src/base/numerics/checked_math.h

CheckedNumeric<T> & operator++ ()

Defined at line 197 of file ../../third_party/mini_chromium/src/base/numerics/checked_math.h

CheckedNumeric<T> operator++ (int )

Defined at line 202 of file ../../third_party/mini_chromium/src/base/numerics/checked_math.h

CheckedNumeric<T> & operator-- ()

Defined at line 208 of file ../../third_party/mini_chromium/src/base/numerics/checked_math.h

CheckedNumeric<T> operator-- (int )

Defined at line 213 of file ../../third_party/mini_chromium/src/base/numerics/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 224 of file ../../third_party/mini_chromium/src/base/numerics/checked_math.h

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

Assignment arithmetic operations.

Defined at line 235 of file ../../third_party/mini_chromium/src/base/numerics/checked_math.h

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

Assignment arithmetic operator implementation from CLASS##Numeric.

Defined at line 333 of file ../../third_party/mini_chromium/src/base/numerics/checked_math.h

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

Assignment arithmetic operator implementation from CLASS##Numeric.

Defined at line 334 of file ../../third_party/mini_chromium/src/base/numerics/checked_math.h

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

Assignment arithmetic operator implementation from CLASS##Numeric.

Defined at line 335 of file ../../third_party/mini_chromium/src/base/numerics/checked_math.h

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

Assignment arithmetic operator implementation from CLASS##Numeric.

Defined at line 336 of file ../../third_party/mini_chromium/src/base/numerics/checked_math.h

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

Assignment arithmetic operator implementation from CLASS##Numeric.

Defined at line 337 of file ../../third_party/mini_chromium/src/base/numerics/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 ../../third_party/mini_chromium/src/base/numerics/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 ../../third_party/mini_chromium/src/base/numerics/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 ../../third_party/mini_chromium/src/base/numerics/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 ../../third_party/mini_chromium/src/base/numerics/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 ../../third_party/mini_chromium/src/base/numerics/checked_math.h

Records

Friends

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