Topic: typedefs and templates


Author: sj@aracnet.com (Scott Johnson)
Date: 1996/08/15
Raw View
I know it is legal to do the following:

template <class T> class Foo;
typedef Foo< int > Bar;

In other words, using typedef to create an instantiation of a template,
and give it a name.

But is it legal (it don't work under GCC 2.7.2) to rename a template using
typedef?  And if it isn't, has this feature ever been considered?B

template <class T> class Foo;
template <class T> typedef Foo<T> Bar<T>;
typedef Bar< int >; // instantiate Bar< int >, which is really Foo< int >

Or even, God forbid:

template <class T> typedef Pointer< T> T*;

(I say "good forbid" because templates instantiations are usually classes
r functions, and a plain vanilla pointer ain't neither.......)


Scott "Geez, I'm full of annoying language extension proposals, ain't I"
Johnson


--
/--------------------------------------------------------------------------\
|Scott Johnson -- Professional (sometimes) SW Engineer and all-purpose Geek|
|I don't speak for nobody but myself, which everyone else is thankful for  |
\--------------------------------------------------------------------------/
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]





Author: vandevod@cs.rpi.edu (David Vandevoorde)
Date: 1996/08/16
Raw View
>>>>> "SJ" == Scott Johnson <sj@aracnet.com> writes:
[...]
SJ> But is it legal (it don't work under GCC 2.7.2) to rename a template using
SJ> typedef?  And if it isn't, has this feature ever been considered?B

SJ> template <class T> class Foo;
SJ> template <class T> typedef Foo<T> Bar<T>;
SJ> typedef Bar< int >; // instantiate Bar< int >, which is really Foo< int >

SJ> Or even, God forbid:

SJ> template <class T> typedef Pointer< T> T*;

Unfortunately not; typedef templates are not part of the
C++ language (yet; and almost certainly won't be part of
the first standard).

 Daveed


[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]