News for hackers. Stuff that matters.
Re:Go by Example by bstamour on Friday January 17, 2014 @12:45PM (#7077185)
With C++14 this becomes

    sort(begin(vs), end(vs),
         [](auto const& l, auto const& r) { 
             return l.size() < r.size(); 
         });
Even simpler.
Re:Go by Example by dmunoz on Friday January 17, 2014 @02:09PM (#7077753)
What are the C++14 parts here? I haven't been paying much attention to the C++14 standards shaking out.

dfrey already asked about why begin/end are functions now.

I see auto being used inside the lambda. Was that not allowed in C++11? I got sucked into the "use auto everywhere" mantra, so I just imagined it was possible, but could easily see if it were not. That is probably the biggest decrease in size to the original code posted.

I see return type inference. That is one thing I have heard about being new in C++14. To be honest, I would rather see the explicit return type there. Inference is always nice, though.

Re:Go by Example by ckarmann on Friday January 17, 2014 @02:25PM (#7077854)
> I see auto being used inside the lambda. Was that not allowed in C++11?

It wasn't:

http://stackoverflow.com/a/7709970/39622

Re:Go by Example by dmunoz on Friday January 17, 2014 @02:33PM (#7077907)
Thanks for the reply. A comment under the accepted answer points to the wikipedia article on C++14, which has information on the new language and new standard library features [0]. I should have thought to check there first.

[0] https://en.wikipedia.org/wiki/C%2B%2B14

Re:Go by Example by bstamour on Friday January 17, 2014 @02:39PM (#7077948)
I omitted the return type (which is allowed for lambdas in C++11, and now arbitrary functions (with some conditions) in C++14) because it was a 1-liner. The bool return type can be deduced by the compiler automatically (or else it would fail to compile) and by the human by the operator < in use, the fact that it's being passed to sort, etc.
Re:Go by Example by dfrey on Friday January 17, 2014 @01:44PM (#7077605)
Why are "begin" and "end" functions now instead of methods on the iterator? Do they consider it better because now you can pass around functions, but not methods?
Re:Go by Example by fauigerzigerk on Friday January 17, 2014 @01:57PM (#7077682)
Because it works with arrays.
Re:Go by Example by bstamour on Friday January 17, 2014 @02:37PM (#7077935)
More than that, actually. Because of argument dependent lookup, this will work for any container that has begin and end functions in the same namespace.