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 32,057 of 33,346   
   Pete Becker to Dave Abrahams   
   Re: Why does range based for loop requir   
   28 Mar 12 10:53:16   
   
   From: pete@versatilecoding.com   
      
   On 2012-03-28 02:46:07 +0000, Dave Abrahams said:   
      
   > on Sat Mar 24 2012, Pete Becker  wrote:   
   >   
   >> On 2012-03-24 05:31:44 +0000, Frank Birbacher said:   
   >>   
   >>>   
   >>> // not allowed in C++11, but I want it to work:   
   >>> int i;   
   >>> for(i : vec) {...}   
   >>>   
   >>   
   >> What should the value of i be after the loop? More generally, what do   
   >> you want to be able to do with i after this loop?   
   >   
   > The value of i is most useful if you break from the loop.  BOOST_FOREACH   
   > supports Frank's usage and frankly I'm surprised to learn that C++11's   
   > native construct doesn't.   
      
   Okay, that's reasonable. But what if you don't exit early? I suppose   
   the value could be the last element, but that's artificial; the "true"   
   value is *end, but end doesn't have to be dereferenceable.   
      
   --   
    Pete   
   Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The   
   Standard C++ Library Extensions: a Tutorial and Reference   
   (www.petebecker.com/tr1book)   
      
      
         [ 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