home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16392 < prev    next >
Encoding:
Internet Message Format  |  1992-11-17  |  1.3 KB

  1. Xref: sparky comp.lang.c++:16392 comp.std.c++:1577
  2. Newsgroups: comp.lang.c++,comp.std.c++
  3. Path: sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!zaphod.mps.ohio-state.edu!uwm.edu!ux1.cso.uiuc.edu!news.cso.uiuc.edu!meibm31.cen.uiuc.edu!pl2440
  4. From: pl2440@meibm31.cen.uiuc.edu (Paul Jay Lucas)
  5. Subject: Re: Proposal - enhancement for switch statement.
  6. References: <1992Nov16.004558.9855@muddcs.claremont.edu> <1992Nov16.213015.1@vax1.bham.ac.uk>
  7. Message-ID: <Bxu298.En3@news.cso.uiuc.edu>
  8. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  9. Organization: University of Illinois at Urbana
  10. Date: Mon, 16 Nov 1992 23:51:07 GMT
  11. Lines: 22
  12.  
  13. In <1992Nov16.213015.1@vax1.bham.ac.uk> mccauleyba@vax1.bham.ac.uk (Brian McCauley) writes:
  14.  
  15. >Now (as promised) why ranges would be unnecessary (following the "if you
  16. >can do it with a class then don't extend the language" rule ;-) )
  17.  
  18. >template <class T> class Range {
  19. >  T top,bottom; 
  20. >public:
  21. >  Range(t,b) : top(t),bottom(b) {} 
  22. >  int operator==(T t) { return bottom <= t && top >= t; }
  23. >}
  24. >template <class T> inline operator == (T& t,Range<T>& r) {return r == t;}
  25.  
  26. >switch (i) {
  27. >  case Range<char>('0','9') : case '-' : {/*...*/} break;
  28. >}
  29.  
  30. *****>    Both cfront 3.0.1 and I think the above is illegal.
  31. -- 
  32.     - Paul J. Lucas                University of Illinois    
  33.       AT&T Bell Laboratories        at Urbana-Champaign
  34.       Naperville, IL            pjl@cs.uiuc.edu
  35.