Boost logo

Boost :

Subject: Re: [boost] Pimpl Again?
From: dariomt (dariomt_at_[hidden])
Date: 2016-06-01 04:29:22


Peter Dimov <lists <at> pdimov.com> writes:
> 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<implementation, void(*)(implementation*)> 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.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk