This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: typeof() in templates
- To: entropy at virek dot vwis dot com
- Subject: Re: typeof() in templates
- From: "Martin v. Loewis" <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Mon, 26 Jul 1999 23:53:19 +0200
- CC: egcs-bugs at egcs dot cygnus dot com
- References: <Pine.LNX.4.10.9907251259030.938-100000@virek.vwis.com>
> template <class AParticle>
> class World
> {
> typedef typeof(AParticle::origin) Position;
> typedef typeof(AParticle::velocity) Velocity;
>
> }
Thanks for your bug report. I have a couple of comments.
gcc-2.95 19990717 does not crash anymore, instead it says
a.cc:5: sorry, not implemented: testing typeof_type for template parms
so it appears the bug is not that bad anymore.
Please note that "typeof" is a g++ extension, so you shouldn't use it
unless you have to. In your example, you don't *really* have to. Your
code assumes that AParticle has an origin member - you could just as
well assume that it has a OriginType member, i.e.
struct MyParticle{
typedef int OriginType;
OriginType origin;
typedef double VelocityType;
VelocityType velocity;
};
Then you can say
typedef typename AParticle::OriginType Position;
which would be standard C++.
Hope this helps,
Martin