pre-boost Home Libraries People FAQ More

PrevUpHomeNext

safe_signed_range<MIN, MAX>

Description
Template Parameters
Model of
Header
Example of use
See Also

Description

This type holds a integer in the range [MIN, MAX]. It will throw a std::out_of_range exception for operation which would result in assigning an integer value outside of this range.

Template Parameters

Parameter Requirements Description
MIN must be an integer literal The minimum integer value that this type may hold
MAX must be an integer literal The maximum integer value that this type may hold
MIN < MAX  

Model of

Numeric

Header

#include <boost/safe_numerics/safe_range.hpp>

Example of use

#include <safe/numeric/safe_range.hpp>

void f(){
    boost::numeric::safe_signed_range<7, 24> i;
    i = 0; // error
    i = 9; // ok
    i *= 9; // throws overflow exception
}

See Also

std::out_of_range


PrevUpHomeNext