How do I use unique_ptr for pimpl?
Solution 1:
I believe that your test_help.cpp actually sees the ~Help()
destructor that you declared default. In that destructor, the compiler tries to generate the unique_ptr
destructor, too, but it needs the Impl
declaration for that.
So if you move the destructor definition to the Help.cpp, this problem should be gone.
-- EDIT -- You can define the destructor to be default in the cpp file, too:
Help::~Help() = default;
Solution 2:
Note this from unique_ptr definition:
std::unique_ptr may be constructed for an incomplete type T, such as to facilitate the use as a handle in the pImpl idiom. If the default deleter is used, T must be complete at the point in code where the deleter is invoked, which happens in the destructor, move assignment operator, and reset member function of std::unique_ptr.