From: "Jeffrey R. Carter" <spam.jrcarter.not@nospam.acm.org>
Subject: Re: Number of possible values in of enumerated type
Date: Mon, 08 Jun 2009 21:45:53 GMT
Date: 2009-06-08T21:45:53+00:00 [thread overview]
Message-ID: <lEfXl.734000$yE1.189050@attbi_s21> (raw)
In-Reply-To: <4a2d7a0f$1_5@news.bluewin.ch>
Gautier wrote:
>
> Did I overlook a specific attribute, or do I always need to write:
>
> Blah'Pos(Blah'Last)+1
>
> for getting the number of possible values of an enumerated type ?
You didn't overlook anything. Note, however, that your solution fails for some
constrained subtypes:
type E is (A, B, C);
subtype F is E range B .. C;
F'Pos (F'Last) = E'Pos (E'Last) = 2, so F'Pos (F'Last) + 1 gives 3, which is a
problem if you want the number of values in subtype F (2). The general solution is
S'Pos (S'Last) - S'Pos (S'First) + 1
--
Jeff Carter
"Now look, Col. Batguano, if that really is your name."
Dr. Strangelove
31
prev parent reply other threads:[~2009-06-08 21:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-08 20:52 Number of possible values in of enumerated type Gautier
2009-06-08 21:45 ` Jeffrey R. Carter [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox