From 4433493598209975663 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f78e5,5be30c38f618a07b X-Google-Attributes: gidf78e5,public X-Google-ArrivalTime: 2002-04-30 17:22:01 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!212.74.64.35!colt.net!kibo.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail From: "James Kuyper Jr." Newsgroups: comp.std.c++ Subject: Re: Why switch w/ only integral types? Date: Wed, 1 May 2002 00:21:12 GMT Organization: Not enough Approved: Fergus Henderson , moderator of comp.std.c++ Message-ID: <3CCF365F.E06A362A@wizard.net> References: <6ee7d287.0203202005.63e0b7b3@posting.google.com> <3CCE6310.672E55DF@webmaster.com> X-Trace: mail2news.demon.co.uk 1020212476 mail2news:27865 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) X-Accept-Language: en MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Date: Tue, 30 Apr 2002 19:14:03 CDT X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-Info: Please be sure to forward a copy of ALL headers X-Abuse-Info: Otherwise we will be unable to process your complaint properly Lines: 33 Xref: archiver1.google.com comp.std.c++:10930 David Schwartz wrote: > > 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? The languages that I'm familiar with that allow such constructs, follow a rule that the case chosen is the first one that matches, even if muliple cases match. --- [ 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 ]