From 2826790144379776261
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,5be30c38f618a07b
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2002-04-30 11:45:02 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!194.213.69.151!news.algonet.se!algonet!newspeer.clara.net!news.clara.net!kibo.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail
From: David Schwartz <davids@webmaster.com>
Newsgroups: comp.std.c++
Subject: Re: Why switch w/ only integral types?
Date: Tue, 30 Apr 2002 18:44:01 GMT
Organization: WebMaster Incorporated
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <3CCE6310.672E55DF@webmaster.com>
References: <6ee7d287.0203202005.63e0b7b3@posting.google.com> <qfpm8.12422$cy2.680922353@newssvr21.news.prodigy.com>
X-Trace: mail2news.demon.co.uk 1020192245 mail2news:25099 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)
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Date: Tue, 30 Apr 2002 09:25:36 +0000 (UTC)
X-Accept-Language: en
Lines: 33
Xref: archiver1.google.com comp.std.c++:10910

Carl Daniel wrote:

> Nevertheless, there are many languages which do permit arbirtray types in
> switch/case constructs, so I doubt there's any technical reason why C++
> couldn't have been specified that way.

	There are reasons. Consider:

MyFoo f;

switch (f)
{
 case 1:
  // code
 case 2:
  // code
}

	What should happen if MyFoo::operator==(int) returns 'true' for both 1
and 2?

	In an event, switch/case is largely obsolete and on many platforms is
actually slower than corresponding if/else code at low levels of
optimization.

	DS

---
[ 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                       ]



