Boost logo

Boost Users :

Subject: Re: [Boost-users] Range checked variable or class
From: Robert Kawulak (robert.kawulak_at_[hidden])
Date: 2009-05-16 06:38:00


> From: Ryan McConnehey
> Neal Becker wrote:
> > How about constrained_value?
> >
> Is that a library or is it part of a bigger library? I can't find it in
> the 1.39 documentation.

Hi Ryan,

You'll find simple constrained_value class in the DateTime library. More
advanced implementation has been reviewed as a separate library and probably
will be added to Boost in the future. I attach some details of this library
below.

Best regards,
Robert

> Here's the library synopsis:
>
> The Boost Constrained Value library contains class templates useful for
> creating constrained objects. A simple example is an object representing an
> hour of a day, for which only integers from the range [0, 23] are valid
> values.
>
> bounded_int<int, 0, 23>::type hour;
> hour = 20; // OK
> hour = 26; // exception!
>
> Behavior in case of assignment of an invalid value can be customized. The
> library has a policy-based design to allow for flexibility in defining
> constraints and behavior in case of assignment of invalid values. Policies
> may
> be configured at compile-time for maximum efficiency or may be changeable
> at
> runtime if such dynamic functionality is needed.
>
> The library can be downloaded from the here:
> http://rk.go.pl/f/constrained_value.zip
>
> The documentation is also available online here:
> http://rk.go.pl/r/constrained_value


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