std::async, and copies – gotcha!

Disclaimer: I love C++11! It’s the best thing that happened to C++ since I’m using it (mid-90’s). I’ve been hoping for lambda‘s in C++ since I discovered and started using Lisp. Elisions and move semantics – together with unique and shared pointers – pretty much free you from thinking about memory management! It’s just amazing! Check out “Going Native” talks on YouTube, incl. amazing talks by the likes of Stroustrup, Sutter, Lavavej, et al.

If you don’t want to read my rant, here’s the point – function objects are objects – they can get copied, unless you specify otherwise, so beware that you’re working on a copy, or pass std::ref.

Continue reading