Boost logo

Boost :

Subject: Re: [boost] Pimpl Again?
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2016-05-31 19:55:54


On Tue, May 31, 2016 at 4:47 PM, Gavin Lambert <gavinl_at_[hidden]>
wrote:

> On 1/06/2016 11:05, rstewart wrote:
>
>> The upside is not writing some calls one way and others the other way on
>>>> the same object, and having to remember which is which.
>>>>
>>>> So, don't use the dot syntax. :)
>>>
>>
>> Not all functions can be non-members.
>>
>
> Operators can be; so the only types of functions I'm aware of that must be
> members are the constructors (regular, copy, and move).
>
> But constructors simply don't exist with this design

Not in the public interface, but they would exist in the private
implementation. Encapsulation is great, all that goodness with constructors
establishing invariants, member functions maintaining invariants,
exceptions enforcing postconditions -- it's all good, but it is now an
implementation detail; all that code lives in the CPP file.

> Moving is not really an issue -- you can move the shared_ptr instead. The
> same applies to shallow copying (copying the pointer rather than the
> underlying object).
>

Yes, but that's different. It's more precise to say that one can't move or
copy an incomplete type.

Emil


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