home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 33,246 of 33,346   
   Dave Harris to All   
   Re: max enum value +1   
   10 Oct 13 10:00:09   
   
   From: brangdonj@googlemail.com   
      
   In article , daniel.kruegler@googlemail.com   
   (Daniel Krügler) wrote:   
   > Am 06.10.2013 21:26, schrieb fmatthew5876:   
   > >> It would anyway have to handle this case:   
   > >>   
   > >> Color white = red|green|blue;   
   > >   
   > > This fails to compile because (red | green | blue) is of type   
   > > int, not Color. You need a cast to do this.   
   >   
   > Yet still the problem described by Bo Persson does exist: It is OK   
   > to define enumeration values "out-of-line" such that they would   
   > have an underlying value that does not exist in any of the   
   > enumerators of the enumeration definition provided it is within   
   > the required limits denoted as "b_min" and "b_max" in 7.2   
   > [dcl.enum] p8.   
      
   I know. I identified that as a problem with the original request in   
   my previous post. It's OK for the language, but need not be OK for   
   the interface. If the enum only has three values, we should be able   
   to write code that only handles those three values. If someone uses   
   a cast to create a value outside those the interface is documented   
   as handling, it's their problem. Same as if they pass a value larger   
   than vector::size() to vector::operator[](), or if they cast away   
   const.   
      
   -- Dave Harris, Nottingham, UK.   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca