From: marc.glisse@gmail.com   
      
   Carlo Milanesi wrote:   
      
   > On 02/11/2011 19:19, topoden wrote:   
   >> On Nov 1, 3:33 pm, Carlo Milanesi   
   >> wrote:   
   >>>   
   >>> Lambda is much more powerful than ranged-for.   
   >>   
   >> The question is actually not why we need lambdas, but why do we need   
   >> std::for_each, given that we now have ranged for loop. I do see the   
   >> need for lambdas, but its a bit unclear to me whats so good in having   
   >> std::for_each in addition to ranged for loops...   
   >   
   > std::for_each was in the standard since 1998, and in STL even before.   
   > Would you deprecate it, forcing every people who used it to convert   
   > their code?   
      
   I don't see a problem with having 2 ways to achieve the same thing in   
   C++. It has always been the case, and often with a number larger than   
   2 ;-)   
      
   > In addition, as I said before, you can use for_each on a subrange, and   
   > you cannot use a ranged-for on a subrange.   
      
   Well, nothing prevents you from putting a subrange cloak over your   
   container (or whatever it is you are iterating on) to make it usable   
   with range-for, if you find it more readable. After all, you only need   
   to convince begin and end to return the extremities of your subrange.   
      
      
   --   
    [ 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)   
|