Hacker News new | ask | show | jobs
by SeanCline 3307 days ago
Well, that isn't a flaw in the implementation of value_ptr. The example, as provided, won't compile because the the copy constructor, assignment operator, and destructor are declared `= default` in the header. This causes any translation units that include value_ptr_example_pimpl.hpp to attempt to stamp out the default implementation, which does require knowing `sizeof(Foo::Pimpl)`.

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...