consistenly use std::memcpy and std::memset