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,006 of 33,346   
   =?ISO-8859-1?Q?Daniel_Kr=FCgler?= to All   
   Re: Why not add a feature to let lambda    
   14 Mar 12 17:12:51   
   
   13e9d5e0   
   From: daniel.kruegler@googlemail.com   
      
   Am 14.03.2012 23:18, schrieb Roman W:   
   > On Tuesday, March 13, 2012 6:57:56 PM UTC, rockeet wrote:   
   >> sometimes a long ugly name may be useful, such as reinterpret_cast, in   
   >> this case the imaged keyword could be 'this_lambda' or 'lambda_self'   
   >> or 'lambda_recursively_call'   
   >   
   > I tried doing something like that:   
   >   
   > int main(void)   
   > {   
   > 	auto recursive_lambda = [](unsigned int n){ return n; };   
   > 	recursive_lambda = [&recursive_lambda](unsigned int n) { if (n<= 1) return   
   static_cast(1); else return n*recursive_lambda(n - 1); };   
   > }   
   >   
   >   
   > but apparently C++ lambdas have no = operator.   
      
   They have a deleted copy-assignment operator, yes. But even if the   
   copy-assignment operator would *not* be deleted, above code wouldn't   
   work, because the second lambda-expression has a different type. In   
   fact, both could *not* be equal, because the second one has another data   
   member that corresponds to the reference-capture "recursive_lambda".   
      
   HTH & Greetings from Bremen,   
      
   Daniel Krügler   
      
      
   --   
         [ 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