|
Boost : |
Subject: Re: [boost] Pimpl Again?
From: Vladimir Batov (Vladimir.Batov_at_[hidden])
Date: 2016-05-30 01:47:11
On 2016-05-30 12:36, Emil Dotchevski wrote:
> My 2c:
>
> In foo.h, instead of
>
> class foo
> {
> class pimpl
> pimpl * p_;
> public:
> foo();
> ~foo();
> void do_something();
> };
>
> It's better to do it the C way: simply leave foo incomplete:
>
> struct foo;
> foo * create_foo();
> void destroy_foo( foo * );
> void do_something( foo * );
>
> The above is much improved using shared_ptr:
>
> struct foo;
> shared_ptr<foo> create_foo();
> void do_something( foo * );
If you are saying that pimpl is conceptually simple, then I agree.
std::unique_ptr is conceptually simple as well.
If you are saying that the snippets you provided are sufficient, then I
have to disagree. Say, pimpl in the context of polymorphic hierarchies
or value pimpls come to mind.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk