Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2002-02-06 14:50:19


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?

Cheers,
Jeremy

On Wed, 6 Feb 2002, rwgk wrote:

rwgk> --- In boost_at_y..., Beman Dawes <bdawes_at_a...> wrote:
rwgk> > Andrei's argument for a single policy based vector rather than
rwgk> several
rwgk> > vector classes is a powerful one. Actually seeing a proposal for
rwgk> what
rwgk> > those policies might achieve would make it easier to form a final
rwgk> > opinion. Policies that no one ever uses just get in the way. But
rwgk> policies
rwgk> > that are really useful become a killer argument, IMO.
rwgk>
rwgk> What are the fundamental differences between policy based
rwgk> implementations and implementations of separate types?
rwgk>
rwgk> >From the user's perspective, I find it much more convenient
rwgk> to refer to std::vector<T> and fix_cap_vector<T> rather than
rwgk> generic_type<T, something_else>. To me the choice of
rwgk> policy-based vs. other approaches seems to be an implementation
rwgk> detail that should be hidden from the user.
rwgk> Unfortunately, ISO C++ does not seem to provide the means
rwgk> to achieve this for policy-based types (see
rwgk> http://groups.yahoo.com/group/boost/message/24334).
rwgk>
rwgk> Ralf
rwgk>
rwgk>
rwgk>
rwgk> Info: http://www.boost.org Send unsubscribe requests to: <mailto:boost-unsubscribe_at_[hidden]>
rwgk>
rwgk> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
rwgk>
rwgk>

----------------------------------------------------------------------
 Jeremy Siek http://php.indiana.edu/~jsiek/
 Ph.D. Student, Indiana Univ. B'ton email: jsiek_at_[hidden]
 C++ Booster (http://www.boost.org) office phone: (812) 855-3608
----------------------------------------------------------------------


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