Boost logo

Boost :

Subject: Re: [boost] [review][constrained_value] Bounded value
From: Robert Kawulak (robert.kawulak_at_[hidden])
Date: 2008-12-03 09:03:54


Hi Edward,

2008/12/3 Edward Diener
> I believe the bounded objects are actually a subset of a larger concept, which is the set of valid values for an object. Ideally what one could have is a set of bounded values which define the valid values. Each member of the set could be a pair ( or two-element tuple ) defining a lower and upper value inclusive, and of course a single value in the set would have its lower and upper value be the same. In this way one could define, as an example, a constrained object whose integer value could be between 0 and 20 and between 50 and 70. Currently the bounded object concept only allows one "bounds". With the larger concept I mention, a bounded object can have any number of bounds. While the single bounds bounded object can still be supported, I would like to see the constrained value library implement a multi-bound concept, in which case the current bounded object concept is just a subset of the multi-bound with a single bound.
>

What you ask for can be easily achieved using the current
implementation. All you have to do is to define a constraint that
encapsulates several within_bounds predicates, each one responsible
for one sub-range of the allowed set.

If you don't care about efficiency or want to use
dynamically-adjustable sets, the task is almost trivial - use
boost::signal as the constraint type and provide a combiner that
returns logical alternative of the results. Then add instances of
within_bounds (or any other predicate) as slots of the signal.

The built-in support for such multi-range sets could be added to the
library too, but I wonder if the use case is common enough and I
should focus on this right now. Anyway, this shuold be easy to achieve
anytime in the future with no modifications to the current
implementation.

Best regards,
Robert


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk