
On Thu, 05 Jun 2014 14:21:04 -0700, Andrzej Krzemienski
It looks from the docs that 'pointer_semantics' implements something like a flyweight. This is so against value semantics.
Not to sound snarky, but pointer semantics is exactly that, pointer semantics, I don't expect it to behave like value semantics.
One of the expectations of types returned by value is that changing the original does no affect the copy: T a = c; T b = c; zap(a); assert(b==c && a!=b); Although the author of class Book knows that it is implemented with pointer_semantics, the users of the class are likely not to know it, and since Book doesn't look like a pointer, they will be expecting value semantics, and will be severely punished.
Unless I'm dealing with pimpl'd classes, then I don't hold that expectation. Granted, it may not be clear from the type name that the type in question is pimpl'd, but I chalk that up to poor naming and language flexibility. The same issue can easily arise with the following bare bone C++ code: // In some header file. typedef some_type * widget; // In some other header file. widget foo(); When dealing with pimpl'd classes, the expected norm (in my experience) for making deep copies is to use the clone function.