Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2005-09-27 13:57:19


From: "Jeff Garland" <jeff_at_[hidden]>
> On Mon, 26 Sep 2005 01:02:25 +0200, Robert Kawulak wrote
> >
> > > Restricted is ok, but I like constrained better. Please see:

Agreed.

> One other thought. The constrained value type fits into a 'value programming'
> classification that eventually I'd like to see expanded in boost. Some other
> parts of this include wrapping_int which has a range and wraps around when you
> do math with it

It sounds like--I've not looked at either class to
know whether this is reasonable--wrapping_int's behavior could be
subsumed by constrained_value. That is, Robert's class could
determine the new value to store based upon calling a policy
function. If that function determines that the new value is out
of range, then it can wrap the value or otherwise adjust it, or
it can signal an error.

Such an approach could actually permit incrementing a
constrained_value that only permits odd numbers. That is,
incrementing would increment to the next odd number. (To support
that would require a fatter policy interface, I expect, so I'm
not saying it would necessarily be a good idea.)

-- 
Rob Stewart                           stewart_at_[hidden]
Software Engineer                     http://www.sig.com
Susquehanna International Group, LLP  using std::disclaimer;

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