Quote Originally Posted by ninja9578 View Post
Why not:
Code:
memmove(&arr2[0], &arr[0], 5 * sizeof(int));
Well, for one thing, memcpy() is always at least as efficient as memmove(), and sometimes moreso. Furthermore, while both of those would be perfectly fine on ints, they would not generalize to any type; for instance, it could cause a crash if you tried it with an array of std::string.

So the "proper" solution if you didn't want to use a loop would be
Code:
std::copy(arr,arr+5,arr2);
This would of course decay to memcpy() internally when instantiated for ints.

Of course, that disregards move semantics. I'm not sure if there's a multi-element form of std::move on any compilers yet, or even if that's going to be the name for that function when there is.