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,654 of 33,346   
   Gene Bushuyev to Cassio Neri   
   Re: lambda objects not assignable   
   21 Nov 12 12:12:45   
   
   From: publicfilter@gbresearch.com   
      
   On Friday, November 16, 2012 1:20:02 AM UTC-8, Cassio Neri wrote:   
   > > > Maybe I'm missing something here, but apart from self-assignment   
   >   
   > > > there isn't any other object of the same closure type, so what would   
   >   
   > > > be the use of copy assignment?   
   >   
   >   
   >   
   > Actually, one can create different objects of the same closure type.   
   >   
   > Consider:   
   >   
   >   
   >   
   > #include    
   >   
   >   
   >   
   > int main() {   
   >   
   >     int i = 1;   
   >   
   >     auto f = [i]() mutable { return i++;};   
   >   
   >     auto g = f;   
      
   It creates a copy of the same closure type, calling copy constructor,   
   it doesn't need assignment. Lambdas are copiable and movable,   
   I think it's sufficent, I don't see where assignment can be practical.   
      
      
   --   
         [ 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