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 32,602 of 33,346    |
|    Ivan Godard to All    |
|    Re: Useful applications for boolean incr    |
|    21 Oct 12 19:20:15    |
   
   From: igodard@pacbell.net   
      
   On 10/21/2012 1:52 PM, Daniel Krügler wrote:   
   >   
   > I would like to know whether there are C++ projects or maybe use-cases   
   > out in the wild that have been found useful applications for the   
   > existing language support of pre- and post-increment on bool values,   
   > such as in:   
   >   
   > bool pre_inc(bool v) { return ++v; }   
   > bool post_inc(bool v) { return v++; }   
   >   
   > Currently, this support is deprecated and the C++ committee is   
   > considering to remove it completely.   
   >   
   > If anyone feels that this removal would break relevant code or idioms,   
   > please respond to this query. Short code examples would be very much   
   > appreciated. If that is not possible, but you can point to projects,   
   > it would be helpful to get links to such projects.   
   >   
   > Thanks && Greetings from Bremen,   
   >   
   > Daniel Krügler   
   >   
   >   
      
   I frequently use increment over an enumeration, typically when iterating   
   over an array whose index set is an enum. This construct is not native   
   to C/C++, but with type traits that give lower/upper bounds for enum   
   types and a little meta-programming you can write:   
    enum E(f, g, h);   
    array
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca