On Thu, May 11, 2017 at 10:23:48AM -0600, Martin Sebor wrote: > Unlike in C, the preferred way to initialize objects in C++ > is to use some form of initialization (as opposed to memset). > The preferred way to copy objects is using the copy ctor or > assignment operator (as opposed to memcpy). Using the special > member functions is clearer, less prone to mistakes and so > safer, and in some cases can also be more efficient. Memcpy > and memset should be reserved for manipulating raw storage, > not typed objects.
But optimizers should be able to turn the copy ctors/assignment operators or default ctors into memcpy or memset where possible, making it efficient again. And that is something that doesn't work well yet. Jakub