Algorithm solution:
std::generate(numbers.begin(), numbers.end(), rand);
Range-based for-loop solution:
for (int& x : numbers) x = rand();
Why would I want to use the more verbose
std::generate
over range-based for-loops in C++11?
Quick Q: When should you make a type non-movable in C++11? -- StackOverflow
So C++11 has these cool move semantics... but when would you not implement move construction and move assignment for your type?
When to make a type non-movable in C++11?
I was surprised this didn't show up in my search results, I thought someone would've asked this before, given the usefulness of move semantics in C++11:
When do I have to (or is it a good idea for me to) make a class non-movable in C++11?
(Reasons other than compatibility issues with existing code, that is.)