$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Hamish Mackenzie (boost_at_[hidden])
Date: 2002-02-06 15:21:57
On Wed, 2002-02-06 at 19:50, Jeremy Siek wrote:
> 
> The closest we can currently come to a templated typedef is to use a type
> generator.
> 
> template <typename A, typename B>
> struct generic {
>   A a;
>   B b;
> };
> 
> // Can't do this
> //template <typename A>
> //typedef generic<A, int> specific;
> //
> // then usage is:  specific<A>
> 
> template <typename A>
> struct specific { typedef generic<A,int> type; };
> 
> // then usage is:   typename specific<A>::type
> 
> Personally, I don't find type generators all that bad. I'd be happy with
> using them all over the place until we get templated typedefs into the
> language. Do other people feel differently?
My only gripe is that they can't be used in partial specialization. But
in most cases that doesn't matter.
That is
template< class T >
class x {}
template< class A >
class x< specific< A >::type > {}
does not work.  But 9 times out of 10
template< class A >
class x< generic< A, int > > {}
is an acceptable workaround.
Hamish