|
Boost : |
From: Beman Dawes (bdawes_at_[hidden])
Date: 2002-02-06 20:15:09
At 02:50 PM 2/6/2002, 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?
What is wrong with forwarding classes (until typedef templates make it into
the language)?
template <typename T>
struct specific_a : public generic<T, policy_a>
{ ... forwarding ctors, etc. };
template <typename T>
struct specific_b : public generic<T, policy_b>
{ ... forwarding ctors, etc. };
At the cost of having to write and maintain more code, doesn't the above
simulate:
template <typename T>
typedef generic<T, policy_a> specific_a;
template <typename T>
typedef generic<T, policy_b> specific_b;
Or am I missing something?
--Beman
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk