
1 Jun
2016
1 Jun
'16
8:29 a.m.
Peter Dimov
Howard Hinnant wrote:
It has to be outlined, in the source.cpp:
class Book { struct implementation; std::unique_ptr<implementation> impl_; public: ~Book(); Book(); };
You could probably do
// hpp class Book { struct implementation; std::unique_ptr
impl_; public: Book(); }; // cpp Book::Book(): impl_( new implementation, checked_delete<implementation> ) {}
Sorry if this is a silly question, but wouldn't this double the size of member variable impl_ (two pointers), just to save some typing? To me it doesn't look like a good tradeoff. I'm quietly following this thread, and I still don't get why std::unique_ptr is not good enough for heap-allocated pimpl.