|
Boost : |
From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2002-04-29 20:44:03
"Andrei Alexandrescu" <andrewalex_at_[hidden]> wrote in message
news:aakk4t$613$1_at_main.gmane.org...
[...]
> 3. Put the specialized trait in a separate file, and ask everyone who
wants
> to use Widget to include that file. This is a discipline-based approach
and
> therefore is error-prone.
>
Here I disagree with you. Even if you have a third party Widget class (in
other case you just put specialization there) you could always provide
WidgetPtr.h header and use it everywhere instead of Widget.h. I do not see a
big problem with that.
For any given generic component to provide customizable behavior one should
use traits iff this behavior is uniquely defined by some other type (it
could be type, subtype or in general any type deducible from template
arguments) defining this component. In other case i.e. if sought-for
behavior is independent (orthogonal) to any other characteristics of given
component one should use policies.
Any attempt to use policies for "type-dependent" behavior may cause
undesirable ambiguity or at best is information duplication: why do I need
to specify policyB if it is uniquely identified by policyA?
Any attempt to use traits to model type independent behavior cause "too
smart" or not flexible enough components.
>
> Andrei
>
Gennadiy.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk