Newsgroups: comp.std.c++
Path: utzoo!henry
From: henry@zoo.toronto.edu (Henry Spencer)
Subject: Re: case()
Message-ID: <1990Aug8.153832.2629@zoo.toronto.edu>
Organization: U of Toronto Zoology
References: <26842@pasteur.Berkeley.EDU>
Date: Wed, 8 Aug 90 15:38:32 GMT

In article <26842@pasteur.Berkeley.EDU> krste@ICSI.Berkeley.EDU ( Krste Asanovic) writes:
>The C/C++ switch statement is very limited as it only allows integer
>expressions. I'd like to suggest a more general case statement.
>The syntax would be,
>
>    case (exp) {
>        case val1 : s1;
>        case val2 : s2;
>        default : sOther;
>    }

Try this, which is already legal C++:

	if (exp == val1)
		s1;
	else if (exp == val2)
		s2;
	else
		sOther;

It is a bit less convenient to type, but does the job.  I greatly doubt
that X3J16 will sanction a new and untried feature which duplicates
an existing one with only a trivial variation in syntax.
-- 
The 486 is to a modern CPU as a Jules  | Henry Spencer at U of Toronto Zoology
Verne reprint is to a modern SF novel. |  henry@zoo.toronto.edu   utzoo!henry
