Boost logo

Boost Users :

From: Graham Reitz (graham.cpp_at_[hidden])
Date: 2008-04-28 17:41:47


I could have sworn I saw an example using boost to do simple numeric
bounds checking.

For example (silly):

enum number_range {A=0,B=1,C=2,D=3,E=4,F=5,G=6,H=7};

class check_number_range
{
    public:
        check_number_range(number_range a_number)
        {
            // Can this check be boostified? <--- Question located here.
            if ((a_number) > -1) && (a_number) < 8))
            {
                // do something
            }
            else
            {
                throw out_of_range;
            }
        }
};

thanks much,
graham


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net