&a is the address of the array; a can be implicitly converted to the address of the first element. Both have the same address, and therefore both values will have the same value when converting to void* .
Are there any pitfalls?
memcpy not typical, so it's pretty easy to write code that compiles but behaves badly; for example, if a was a pointer, not an array, then sizeof a will compile, but give the wrong value. C ++ type templates can protect against this:
std::copy(b, std::end(b), a); // will only compile if `b` has a known end.
source share