Pimpl-ization

Michael Stahl mstahl at redhat.com
Thu Dec 11 07:01:04 PST 2014


On 11.12.2014 13:49, Bjoern Michaelsen wrote:
> Pimpl 
> 
> (HXX):
> 
> class AnotherThing;
> class RealThing;
> 
> struct Thing {
>     Thing(AnotherThing* pAnother);
>     void DoSomething()
>         { m_pImpl->DoSomething() }
>     void DoSomethingElse()
>         { m_pImpl->DoSomethingElse() }
>     ...
>     std::unique_ptr<RealThing> m_pImpl;
> }
> 
> (CXX):
> 
> struct RealThing SAL_FINAL {
>     RealThing(AnotherThing* pAnother)
>         : m_pAnother(pAnother) {}
>     void DoSomething();
>     void DoSomethingElse();
>     AnotherThing* m_pAnother;    
> }
> 
> Thing::Thing(AnotherThing* pAnother)
>     : m_pImpl(new(RealThing(pAnother)))
> {}
> 
> RealThing::DoSomething()
> { .... }
> RealThing::DoSomethingElse()
> { .... }

forward every single method to a method of the pimpl class?  i've never
seen anybody do that; usually the pimpl class only has public members
and "private" methods (that shouldn't be mentioned in the header file
anyway) which is a bit simpler than your straw-man.




More information about the LibreOffice mailing list