Hacker News new | ask | show | jobs
by jcd748 4446 days ago
You probably don't need std::for_each anymore. With C++11, you can do the following:

for (const auto& element : collection) { }

What's wrong with <algorithm>? I use it all the time for sort, swap, and random_shuffle comes up more frequently than I expect.

1 comments

Those are all fine. Actually, I forgot that sort was in <algorithm>. I was just recalling some of the horrors I've seen due to pre-C++11 fanciness. There seems to be a temptation for C++ programmers to overuse clever tricks. Luckily, with C++11 fewer tricks are necessary.

Unfortunately, the gamedev industry will probably be stuck with pre-C++11 for another decade.

> I'm a C++ expert ..

> I forgot that sort was in <algorithm>

Uhm, sillysaurus3, could I see you in my office please.

:-)

My brain space is limited, so I use it sparingly. Memorizing which header file provides which function is something I've left out. That's what IDEs and Google are for. ;)