Under what conditions is it safe to use std::memcpy to copy between objects?
问题 Under what set of conditions is it safe to use std::memcpy to copy from one object to another? For example, what conditions must T , src and dest satisfy for the following to be safe: template <typename T> void copy_bytewise(T& dest, const T& src) { std::memcpy(&dest, &src, sizeof(T)); } The only thing we can assume about src and dest is that they don't overlap 1 . In particular either of src or dest may be a reference to a member or base class. I am interested in answers which refer to the