Boost logo

Boost :

Subject: Re: [boost] Pimpl Again?
From: Vladimir Batov (Vladimir.Batov_at_[hidden])
Date: 2016-05-31 02:22:52


On 2016-05-31 13:41, Emil Dotchevski wrote:
> On Sun, May 29, 2016 at 10:47 PM, Vladimir Batov <
> Vladimir.Batov_at_[hidden]> wrote:
>> On 2016-05-30 12:36, Emil Dotchevski wrote:
>>
>>> 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 * );
>>
> ...
> Polymorphism -- the snippets I provided are sufficient, virtual
> function
> calls work just fine. For example, in the CPP file you could define
> do_something (see above declaration) like so:
>
> void do_something( foo * p )
> {
> p->do_something(); //virtual
> }
> ...

Indeed. You right... Once we take the methods out to be free-standing
functions, there is nothing left of the interface/proxy class but
shared_ptr<foo>... I have to admit it never occurred to me... :-) Not
sure if I am ready to do things your way :-) but you are most certainly
correct. Thank you.


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