From 6901769925657004254
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,fe27635c57b20d94,start
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2002-03-05 20:40:08 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!newsfeed00.sul.t-online.de!t-online.de!newsfeed.wirehub.nl!shale.ftech.net!news.ftech.net!dispose.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail
From: "Garry Lancaster" <glancaster@ntlworld.com>
Newsgroups: comp.std.c++
Subject: Base class can't be typedef. Why?
Date: Wed,  6 Mar 2002 04:39:35 GMT
Organization: ntlworld News Service
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <XI7h8.103182$Ah1.14149867@news2-win.server.ntlworld.com>
X-Trace: mail2news.demon.co.uk 1015389579 mail2news:11089 mail2news mail2news.demon.co.uk
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2615.200
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
NNTP-Posting-Date: Tue, 05 Mar 2002 18:00:23 GMT
Lines: 55
Xref: archiver1.google.com comp.std.c++:9884

Dear All

Am currently writing some somewhat hairy template
code that involves me deriving from a class type that
is buried deep within a load of templated and typedef'd
code. And therein lies the problem. I want to use
a typedef to simplify my base class type e.g. I want
to write

typedef my_incredibly_long_type_name short_name;

class derived : public short_name
{...};

rather than

class derived : public my_incredibly_long_type_name
{...};

(In reality the long name is even longer and I
use it elsewhere making the typedef more beneficial
than in this cut down example.)

However para 7.1.3/4 of the standard says:

"A typedef-name that names a class is a class-name (9.1).
If a typedef-name is used following the class-key
in an elaborated-type-specifier (7.1.5.3) or in the
class-head of a class declaration...the program is ill-formed."
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The class-head includes the part that specifies
base classes. Therefore I am prevented from
using my typedef name there.

Is my interpretation of the standard correct? If so,
what is the rationale behind this decision?

It seems bizarre; after all, I can quite happily use
my typedef name to declare a data member. And
what is a base class in reality but a data member
with a bit of extra compiler magic thrown in?

Kind regards

Garry Lancaster
Codemill Ltd
Visit our web site at http://www.codemill.net

---
[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]



