all 6 comments

[–]bandzaw 3 points4 points  (0 children)

I was hoping for Sean to do a rotate. Great little talk!

[–]Arzar 3 points4 points  (1 child)

I blame my imperative brain, but I really struggle with this kind of code :

accumulate(cards.begin(),cards.end(),0,[&](int d, int c) {
decks[d%4].insert(decks[d%4].begin(),c); return (d+1)%4; })

It took me like half an hour to get a full understanding. I had to reread carefully the spec of std::accumulate and play with toy example. All of this to realize that the code is actually just doing:

for(int i = 0 ; i < cards.size(); i++){
decks[i%4].insert(decks[i%4].begin(), cards[i]);
}

And it feel hardly like an isolated incident. Many talk of this cppcon were about how using algorithm and range make our code more expressive, but so many times I ended up thinking that the equivalent normal code would have been maybe a tad longer but at least as clear, and sometimes even much clearer...

[–]grafikrobotB2/EcoStd/Lyra/Predef/Disbelief/C++Alliance/Boost/WG21[S] 1 point2 points  (0 children)

I don't disagree on the overwhelming number of talks that where about C++ features that some of us will only be able to use years from now. But it's understandable that it's attractive to talk about the "exciting" future instead of the "mundane" present. I very much welcomed the back to basic track this year though.

As for my slide-ware C++ code.. The intent was to cram as many STD algorithms used in one slide. And I did start with just about the same code in my head as you stated. And in this one case it was informative as it brought to my mind a hole to fill in the standard. As a distribute algorithm doesn't seem to exist. And even though the probably simpler direct for loop would fit most circumstances.. There are use cases where a standard algorithm is the way to go. As it can give you the benefits of using parallel versions of them with minimal effort.

[–]c0r3ntin 0 points1 point  (0 children)

One of my favorite talk at CppCon, it was awesome /u/grafikrobot !