Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2004-04-04 05:42:17


"David Abrahams" <dave_at_[hidden]> wrote
> "Andy Little" <andy_at_[hidden]> writes:
>
> > "David Bergman" <davidb_at_[hidden]> wrote
> >> David A. wrote:
> >> > "Andy Little" <andy_at_[hidden]> writes:
> >
> > [snip]
> >
> >> > > Surely a trait is *part of the *definition* * of an *entity* in a
> >> > > wider sense.
> >> >
> >> > I think I just quite definitively disagreed with that
> >> > assertion already ;^)
> >>
> >> Would you disagree with Andy even if that "wider sense" was a GP
concept?
> >
> > I guess that David Abrahams is taking me to task on use of the word
'entity'
> > which is defined in the standard (3-3).
>
> No, I'm not. Just read the words I wrote. I simply reject the idea
> that a trait specialization is part of the definition of the type(s)
> it applies to.

hmm ..From the latest qualifications of your objections above I now assume
you are seeing this.

struct traits<T>
{
...
};
Where traits is the subject, traits<T> is Not part of T's definition.

But we have been discussing numeric::converter and std::basic_string and
differences between traits and policies... I have been seeing this :

template <typename T>
struct T1{
    typedef traits<T> arg_traits;
};
Where T1 is the subject, traits<T> Is part of T1's definition. Also see
standard 21-2 relating to strings. " <strings> ..need a set of related
types... to complete the definition of their semantics".

-----------

The traits or policy discussion seems to boil down to this:

In T1 above arg_traits is not user modifiable, However

template <typename T,typename P>
struct T2{
    typedef P arg_traits;
};

arg_traits in T2 is user-modifiable. traits<T> is a traits-class, but
traits<T> could theoretically be used in T2, in which case it would be
regarded as implementing a policy. To implement various policies one can
define different traits-classes on the same type, however they might then be
best referred to as policy-classes. Use of traits<T> in T1 could also be
regarded as a policy, but an immutable one. Based on that one could say that
a policy is implemented, simply the Use of a traits-class or a
policy-class. The term policy being useful only if the policy is modifiable.

regards
Andy Little


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