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,048 of 33,346   
   Joe Gottman to Pete Becker   
   Re: Why does range based for loop requir   
   24 Mar 12 18:21:46   
   
   From: josephgottman@comcast.net   
      
   On 3/24/2012 7:35 AM, 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?   
   >   
      
     I'd expect the value to be the last value assigned to the variable,   
   just as with any other variable.  So this would be the value of the last   
   element of the collection,  unless break had been called or the   
   collection was empty. I admit this would not be particularly useful, but   
   I don't see any reason to make this code illegal.   
      
   Joe Gottman   
      
      
   --   
         [ 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