by SeanCline · 9y ago · 0 comments
Looking at the author's code on GitHub, this implementation seems decent.
One thing to note about this implementation is that it doesn't address the other big reason for doing dynamic allocations: polymorphic types. Value semantics are preserved so faithfully that objects are sliced just as they would be if they weren't dynamically allocated.
Consider this example: https://gist.github.com/SeanCline/c81218e4c0208ccb871268aecd...
Moving those methods to value_ptr_example_pimpl.cpp, just as you'd normally do for PIMPL makes the compiler happy.
This works for me in VS2017 but should work on any C++11 compliant compiler: https://gist.github.com/SeanCline/55d700d4fbf8cc1bdaeb44b547...