From 8809059269130147161
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,11af4794c44339e8
X-Google-Attributes: gidf78e5,public
From: wmm@fastdial.net
Subject: Re: Can you static_cast between enums?
Date: 1999/12/18
Message-ID: <83gnm6$u1f$1@nnrp1.deja.com>#1/1
X-Deja-AN: 562470334
X-NNTP-Posting-Host: 206.113.34.194
Approved: stephen.clamage@sun.com (comp.std.c++)
References: <ktA14.377$6A5.16841@dfiatx1-snr1.gtei.net> <832fub$t0$1@news.hamburg.pop.de> <385AA7AA.8D983B3@tribble.com>
X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)
X-Http-Proxy: 1.1 x42.deja.com:80 (Squid/1.1.22) for client 206.113.34.194
Organization: Deja.com - Before you buy.
X-Article-Creation-Date: Sat Dec 18 19:35:34 1999 GMT
X-MyDeja-Info: XMYDJUIDwmmj16
Newsgroups: comp.std.c++
Originator: clamage@taumet


In article <385AA7AA.8D983B3@tribble.com>,
  David R Tribble <david@tribble.com> wrote:
>
> "J.Barfurth" wrote:
> [...]
> > After that paragraph follow the interesting rules, which tell you
what
> > static_cast can do, but can't be done without a cast.
> > The relevant one states that static_cast can convert from any
integral
> > type to an enumeration type. As others have stated that does not
allow
> > the cast from one enumeration type to another.
>
> So what does the following expression do, in terms of the xxx_cast
> operators?
>
>     enum Color { RED, WHITE, BLUE };
>     enum Hue { R, W, B };
>
>     Hue  h = (Hue)RED;   // not static_cast<Hue>(RED)?

None of the casting mechanisms -- "(Hue)RED", "Hue(RED)", and
"static_cast<Hue>(RED)" -- allows this conversion, according to
the current wording of the standard.  As I said earlier in this
thread, this is an oversight and is expected to be corrected in
the first Technical Corrigendum.
--
William M. Miller, wmm@fastdial.net
OnDisplay, Inc. (www.ondisplay.com)


Sent via Deja.com http://www.deja.com/
Before you buy.


[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]




