Pimpl copying

Peter Kümmel syntheticpp at gmx.net
Sat Jul 15 09:30:48 BST 2006


Alexander Petrov wrote:
> Hi
> 
> On Friday 14 July 2006 01:05 Peter Kümmel wrote:
>> Shouldn't we introduce a coding policy something like this:
>>
>> Index: ktempdir.h
>> ===================================================================
>> +#define KDE_PIMPL_BASE_MACRO(COPY_ACCESS,X) \
>> +COPY_ACCESS: \
>> +       X(const X##&); \
>> +       X##& operator=(const X##&); \
>> +private: \
>> +       class X##Private; \
>> +       X##Private* const d;
>> +
>> +#define KDE_PIMPL_COPYABLE(X)   KDE_PIMPL_BASE_MACRO(public, X)
>> +#define KDE_PIMPL_UNCOPYABLE(X) KDE_PIMPL_BASE_MACRO(private,X)
> []
>> This introduces a new macro KDE_PIMPL_COPYABLE
>> which declares the pimpl AND the copy functions.
>>
>> KDE_PIMPL_UNCOPYABLE declares the copy functions
>> as private, so we get an error at compile time.
> 
> everybody hates macros
> take a look at boost.pimpl, announced at 
> http://lists.boost.org/boost-announce/2006/05/0090.php
> there is only template code, which behaves far more better, than macros
> 
>> Peter
> 

I know boost pimpl, it was recently rejected.

I also prefer a template version and had I proposed a template
based solution here on the list, but there was no interest.

http://lists.kde.org/?l=kde-core-devel&m=113981417304925&w=2

Maybe it becomes more interesting when I threat to do it with a macro. :)

I will have a look at the template version again, and try to
incorporate the copying stuff.

Peter





More information about the kde-core-devel mailing list