Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2004-04-05 15:48:20

"Rob Stewart" <stewart_at_[hidden]> wrote
> From: "Andy Little" <andy_at_[hidden]>

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

Yes I see what you mean, a typedef is not a very good example of Use of a
traits-class by another class.
Perhaps more like this:

template<typename T>
struct adjust_traits;

template <typename T>
class adjust{
    typename adjust_traits<T>::feedback_type operator()
    (typename adjust_traits<T>::output_type const& out );

class brightness;
class roll_rate;
template <>
class adjust<brightness>;
class adjust<roll_rate>;

( BTW your other post in this thread I am pretty much in agreement with. One
point worth making. Perhaps I should use the term *traits-class*,
rather than *trait* or *traits*.I guess a trait is a member of a
traits-class and traits are members of a traits-class.
 I have not been following that advice...but meanwhile this thread has
cleared up some foggy
ideas .. so it has been very helpful to me.

Andy Little

> > 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
> > 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
> 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;
> _______________________________________________
> Unsubscribe & other changes:

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