From: Rob Stewart (stewart_at_[hidden])
Date: 2005-09-28 09:33:56
From: "Robert Kawulak" <kawulak_at_[hidden]>
> >From: Rob Stewart
> The policy interface is indeed fatter, it contains the following five
> functions (the version I'm currently working on, not published yet):
> initialize() - returns a value used to default-initialize a constrained
It seems that you'd want it to take a non-const reference to
> is_valid_value(value) - returns false if assignment of the value to
> a constrained object would be an error (used to verify if a value input
> from a stream is correct);
I think "is_valid" is sufficient.
> assign(variable, new_value) - performs assignment of new_value to the
> variable holding the value of a constrained object;
> increment(variable) - increments the variable holding the value of
> a constrained object;
> decrement(variable) - decrements the variable holding the value of
> a constrained object.
> increment() and decrement() are added for efficiency reasons (in case of
> bounded types you need only one comparison and increment/decrement instead
> of addition, two comparisons and assignment). However, there are no policy
> functions for +=, *= etc. - this would make the whole constrained types
> thing too messy. Increment and decrement are just so common, and the
> efficiency gain seems to be significant enough, that I've decided to put
> them there.
> BTW in the current version I've changed the name of basic_bounded template
> to constrained_type (I don't like constrained_value name which may be
> misleading, because it's a type of values rather than a value itself), and
I'm confused. I thought the whole point of your library was to
create an object that *has* a value and to constrain that value
to be a member of a prescribed set. That's how you can add them
together, increment them, etc. Thus, "constrained_value" is
exactly the right name.
Given that, you do need to implement, though not necessarily
through the policy class, the arithmetic assignment operators,
and everything else that will make these act like built-in types.
-- 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