Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2004-04-05 08:26:33

From: "Andy Little" <andy_at_[hidden]>
> "David Abrahams" <dave_at_[hidden]> 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".

I see this:

template <typename T>
class T3

That is, "traits<T>" isn't part of the interface of T3
specifically, though nested types in it could be. I see
traits<T> as an implementation detail injected from the scope
where traits<T> is specialized.

> 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
In which case, they aren't traits classes to me.

> 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.

Yes, but it is equally important, in my mind, that a traits class
has a well-known, ubiquitous name. Anywhere you want a
particular trait or set of traits for a type T, you always use
the same traits class, xxx<T>. The name of a policy is valuable
when selecting it from among the set of available policies and to
clarify intent in a specialization, but in use, its alias -- the
template parameter name -- is important.

Rob Stewart                           stewart_at_[hidden]
Software Engineer           
Susquehanna International Group, LLP  using std::disclaimer;

Boost list run by bdawes at, gregod at, cpdaniel at, john at