comp.lang.ada
 help / color / mirror / Atom feed
From: "Xenos" <dont.spam.me@spamhate.com>
Subject: Re: access & address
Date: Fri, 15 Oct 2004 13:09:01 -0400
Date: 2004-10-15T13:09:01-04:00	[thread overview]
Message-ID: <ckp07i$dlm3@cui1.lmms.lmco.com> (raw)
In-Reply-To: 0hSbd.106246$dP1.397440@newsc.telia.net

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1502 bytes --]


"Bj�rn Persson" <spam-away@nowhere.nil> wrote in message
news:0hSbd.106246$dP1.397440@newsc.telia.net...
Xenos wrote:

>> If you define an enum such as:
>>
>> enum month {First_Month = 0, Last_Month = 12};
>>
>> The C++ standard says that any value within the range is valid (actually
its
>> any value less than or equal to the closed power of 2, not less than 12,
but
>> close enough).

>So I can assign 15 to it? Which month would that be? And which month is
>number 0? That's not what I call "close enough".

No, perhaps my example was a little too simplicistic, or you knew what I
meant and just choose to be snide.  By "close enough" I was referring to my
explination of the standard.  0 was a type-o, and beg your forgiveness for
making one.  I know that when I am writing in Ada, I magically never make
one and you must not either.  First, you can't assign 15 to it, you can't
assign an integer to an enum in C++ without an explicit cast.  My point was
that just specifying the upper bound is good enough to guarantee the
language internally uses an integer type with a big enough range to
accomodate you.  If I were to actually do months is would be something like:

enum months {january, february, .... , december};

and not use numbers.  The example was just to show you how you could make
the template types unique without needing to define another class.  The
ranged class should by defined in such a way that only its base type T (in
this case months) is castable to it.

regards.






  reply	other threads:[~2004-10-15 17:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-14  9:05 access & address Hans Van den Eynden
     [not found] ` <1347924.5V7QhTSfdI@linux1.krischik.com>
     [not found]   ` <ckm14i$erb2@cui1.lmms.lmco.com>
2004-10-14 18:09     ` Martin Krischik
2004-10-14 20:13       ` CBFalconer
2004-10-15  8:18         ` Martin Krischik
     [not found]     ` <2t7jm8F1sp752U1@uni-berlin.de>
2004-10-14 18:17       ` Martin Krischik
2004-10-14 19:52         ` Xenos
2004-10-15  8:53           ` Martin Krischik
2004-10-15 17:30             ` Xenos
2004-10-16 14:25               ` Martin Krischik
2004-10-16 15:15                 ` Rich Herrick
2004-10-15 15:46           ` Björn Persson
2004-10-15 17:09             ` Xenos [this message]
2004-10-17 23:38               ` Björn Persson
2004-10-18  7:42                 ` Martin Krischik
2004-10-14 19:37       ` Xenos
2004-10-15  8:30         ` Martin Krischik
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox