From 2035367064180041209
X-Google-Thread: f78e5,c818ee5949b522b9
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news1.google.com!news3.google.com!news.glorb.com!newsgate.cistron.nl!newsfeed.stueberl.de!newsfeed.vmunix.org!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull
From: brangdon@cix.co.uk (Dave Harris)
Newsgroups: comp.std.c++
Subject: Re: is iterating over an enum conformant?
Date: Fri, 24 Jun 2005 14:00:36 GMT
Lines: 28
Sender: mail2news@demon.net
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <memo.20050624111627.3032A@brangdon.m>
References: <1119522569.944334.120800@z14g2000cwz.googlegroups.com>
NNTP-Posting-Host: news.news.demon.net
X-Trace: news.demon.co.uk 1119621658 27990 158.152.254.254 (24 Jun 2005 14:00:58 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Fri, 24 Jun 2005 14:00:58 +0000 (UTC)
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Orig-X-Trace: individual.net JmkwluLJtuejeszs7he8ige1iJiYSZeF6w4jilOqowaWT6sdk=
X-Virus-Scanned: amavisd-new at cs.mu.OZ.AU
X-Reply-To: brangdon@cix.co.uk
X-Received: (from fjh@localhost)
	by mulga.cs.mu.OZ.AU (8.12.10+Sun/8.12.9/Submit) id j5OE0axC010761;
	Sat, 25 Jun 2005 00:00:36 +1000 (EST)
X-Path: comp-std-cpp-robomod!not-for-mail
X-Delivered-To: std-c++@ucar.edu
X-Spamscanner: mailbox7.ucsd.edu  (v1.6 Apr  6 2005 07:48:50, 0.0/5.0 3.0.0)
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Newsgroups: comp.std.c++
X-MailScanner: PASSED (v1.2.8 60741 j5OALWgd063730 mailbox7.ucsd.edu)
Xref: g2news1.google.com comp.std.c++:5201

dishsi@tin.it (Gianluca) wrote (abridged):
> A doubt slipped into my mind. I wonder if this piece of code is ok from
> the standard point of view (the idea comes from real life, but the
> example is totally artificial):
> 
> enum eEnum { eE1 = 0, eE2, eE3, eTotal };
> 
> int anArray[eTotal] = {};
> 
> int main()
> {
>   for (int i(eE1); i < eTotal; ++i)
>   {
>      anArray[i] = i;
>   }
> }

It's fine, as long as the int is big enough to hold all the values of the 
enum. What made you doubt it would be OK?

-- Dave Harris, Nottingham, UK.

---
[ 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.jamesd.demon.co.uk/csc/faq.html                       ]



