Replace memcpy with std::copy_n