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,258 of 33,346   
   Dave Abrahams to All   
   Re: What does bind offer that lambdas do   
   07 May 12 19:41:49   
   
   c5daf87f   
   From: dave@boostpro.com   
      
   on Mon May 07 2012, nroberts  wrote:   
      
   > Stepping through a binder invocation is actually fairly annoying.  The   
   > argument list calculation stuff takes quite a few calls.  On the other   
   > hand, stepping through a lambda is much clearer and resembles more   
   > standard function call debugging.  With that in mind it seems that one   
   > should prefer lambda expressions over bind expressions pretty much   
   > whenever both can be used.   
   >   
   > It seems to me that lambda can do everything that bind can do and so   
   > if you follow that rule you'd never use bind at all.  Yet both were   
   > included in the standard...   
   >   
   > So is there anything that bind does better than lambda or anything   
   > that bind can do that lambda cannot?   
      
   bind-ish things can do compile-time polymorphism:   
      
            struct FunctionObject   
            {   
                 template    
                 void operator()(T, U) { .... }   
            }   
      
            std::bind(FunctionObject(), _1, 42)("foo")   
              ==> returns FunctionObject()("foo", 42)   
      
   lambdas require you to specify the parameter types.   
      
   --   
   Dave Abrahams   
   BoostPro Computing   
   http://www.boostpro.com   
      
      
         [ 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