|
Boost : |
From: Robert Bell (belvis_at_[hidden])
Date: 2004-05-17 13:54:38
christopher diggins wrote:
> ----- Original Message -----
> From: "Rob Stewart" <stewart_at_[hidden]>
> [snip]
>
>>That is a problem, but so too is the increasing pain of
>>specifying a desireable combination of policies. What about
>>using a single policy argument with everything combined? That
>>means you can use a single class (template) or use a class
>>template that permits specifying various pieces -- not unlike
>>shown above -- into one class that can be the constrained_value
>>parameter.
>>
>>The advantage of this approach is that it gives the policy
>>authors greater flexibility. They can write monolithic policy
>>classes, if desireable. They can assemble a class template that
>>gives select configurability or one that makes it possible to
>>supply each policy independently as you've shown. As part of the
>>library, you could even supply the latter class template, so the
>>library would support both extremes out of the box.
>
>
>
> I agree. I just posted a latest version at
> http://www.cdiggins.com/constrained_value.hpp which has only has two
> policies passed to a constrained_value type, a constraints_policy and an
> implicit_conversion flag. This flag I believe is best left out of the
> constraints_policy but I could be convinced otherwise.
>
> There is now a small demonstration program at
> http://www.cdiggins.com/cv_test.hpp which has some example policies.
Some quick notes:
-- The default constructor of constrained_value initializes the member
"m" by calling the min() function, which isn't present.
-- The test program is at http://www.cdiggins.com/cv_test.cpp.
-- In the test program, throwing_invalid_policy should throw
exception(), not exception, and allowing exception to default to void
won't compile (can't throw void).
-- throwing_invalid_range just uses "throw;", but doesn't appear to be
called from inside a catch handler.
Aside from that, it's looking pretty interesting.
Bob
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk