pre-boost Home Libraries People FAQ More

PrevUpHomeNext

safe_unsigned_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 any operation which would result in assigning an integer value outside of this range.

Template Parameters

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

Model of

Numeric

Header

#include <safe/numeric/safe_range.hpp>

Example of use

#include <safe/numeric/safe_range.hpp>

void f(){
    boost::numeric::safe_unsigned_range<7, 24> i;
    i = 0;  // throws out_of_range exception
    i = 9;  // ok
    i *= 9; // throws out_of_range exception
    i = -1; // throws out_of_range exception
}

See Also

std::out_of_range


PrevUpHomeNext