I'm not sure that, strictly speaking, the standard allows you to memcpy into a char array and vice versa, although you will probably leave with it using POD.
But things get duller when you start looking at all the complicated things that C ++ can do. Consider the following:
struct ex1; struct ex2 { ex2(std::unique_ptr<ex1> ptr) : member{ptr} {} private: std::unique_ptr<ex1> member; };
Line ex2 is just a move, because it has an element variable just for moving. So what happens if we use memcpy to create a bit-bit identical copy of an ex2 instance? We get two objects that both think they have a pointer to a member. What happens when the second one is removed? You get the idea.
Tristan Brindle 07 Oct '14 at 3:22 2014-10-07 03:22
source share