This question has been bothering me for some time. The possibilities I am considering are
Does a
memcpy
is probably the fastest way to copy a contiguous block of memory. This is because it will likely be highly optimized to your particular bit of hardware. It is often implemented as a built-in compiler function.
Having said that, and non POD C++ object is unlikely to be contiguous and therefore copying arrays of C++ objects using memcpy
is likely to give you unexpected results. When copying arrays (or collections) of C++ objects, std::copy
will use the object's own copy semantics and is therefore suitable for use with non POD C++ objects.
cblas_dcopy
looks like a copy for use with a specific library and probably has little use when not using that library.