This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: typeof() in templates


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]