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,656 of 33,346    |
|    Matt Calabrese to MJanes    |
|    Re: lambda objects not assignable    |
|    21 Nov 12 12:15:43    |
      From: rivorus@googlemail.com              On Friday, November 16, 2012 4:20:11 AM UTC-5, MJanes wrote:       > On Tuesday, November 13, 2012 8:51:22 PM UTC+1, Gene Bushuyev 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?       >       > it's common for generic code to accept functors by value ( including       > the STL ); therefore, non-copy-assignable lambdas would be nearly       > useless ...              +1              > On Thursday, November 15, 2012 2:17:25 AM UTC+1, Zhihao Yuan wrote:       > > I think this is the main reason -- lambda types are identical to each       > > other, and both the lambda and their type are unnamed. Assignment does       > > not work with different types. And self-assignment is impossible,       > > because lambda is a prvalue.       >       > the fact that lambdas and their types are unnamed it's not relevant,       > beacuse you can always write template code deducing the lambda type       > and instantiating it however you like. Moreover, lambdas can have       > state so they are not always identical to each other ...       >       > Personally, I agree with the OP that adding assignability to lambdas       > would be useful to write and use functor-based copyable wrappers ala       > boost transform iterator; maybe, even code like the above + STL       > containers could turn out useful on occasions ...              Agreed on everything. In my opinion, it's sort of an embarrassment       that types such as arrays in C++ are not copyable and not       copy-assignable. Unfortunately, we have to deal with that, making it       difficult to use such types in generic code. I do not see any solid       rationale for lambdas to not be regular or semiregular types and in       this case we can't really blame our current situation on C. Lambdas       should be copyable and copy-assignable, plain and simple.                     --        [ 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