|
Boost : |
From: Rob Stewart (stewart_at_[hidden])
Date: 2004-05-17 11:05:43
From: "Jeff Garland" <jeff_at_[hidden]>
>
> I'm starting to think that Pavel is correct about the orthogonal policies.
I agree with that as an ideal, but practicalities often
intervene.
> Maybe we need this to be something like:
>
> template<
> typename ConstraintPolicy,
> typename ErrorPolicy=default_error_policy,
> typename ImplicitConversionPolicy=allow_implicit_conversion,
> typename CheckingPolicy=checking_on>
> class constrained_value
> {
>
> The downside I see here is that errors get much uglier.
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.
-- 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