News for hackers. Stuff that matters.
Re:The New C++: Lay down your guns, knives, and clubs by yonilevy on Sunday June 12, 2011 @09:29AM (#2646442)
It sounds like you're referring to C++98 while the article specifically talks about C++0x. C++0x adds closures to the mix so it's now very possible to implement something similar to .NET LINQ in C++.
Re:The New C++: Lay down your guns, knives, and clubs by barrkel on Sunday June 12, 2011 @09:47AM (#2646467)
No, I'm not; I explicitly mentioned closures which capture state precisely because that's where C++0x gets thorny. You can capture by copying or by reference; what you don't get is wholesale movement of the variable into a heap-allocated location, the way variable capture works in almost every other language supporting free mutation of variables.

I wrote about it in an earlier thread: http://news.ycombinator.com/item?id=2617990

Re:The New C++: Lay down your guns, knives, and clubs by yonilevy on Sunday June 12, 2011 @01:15PM (#2646855)
My bad, I wasn't familiar with the term. I'm still not convinced this is a limitation though. If you want to modify an object, passing by reference usually makes perfect sense. For those occasion when this is not the case, you probably already have a smart pointer in your hand, capture it by copy. A counter example would be great.

BTW the behavior you describe has been achieved in the C language family with Apple's C block extension, not that it's relevant since it's in no way standard (aside from Objective-C++)