Pimpl copying

Peter Kümmel syntheticpp at gmx.net
Sat Jul 15 08:26:52 BST 2006


Michel Hermier wrote:
>> --- kdemacros.h.cmake   (revision 562532)
>> +++ kdemacros.h.cmake   (working copy)
>> @@ -413,8 +413,8 @@
>>
>>  #define KDE_PIMPL_BASE_MACRO(COPY_ACCESS,X) \
>>  COPY_ACCESS: \
>> -    X(const X##&); \
>> -    X##& operator=(const X##&); \
>> +    X(const X &); \
>> +    X & operator=(const X &); \
>>  private: \
>>      class X##Private; \
>>      X##Private * const d;
>>
>> Is this a gcc bug or is X##& an invalid preprocessor command?
>>
> 
> For me X##& is an invalid preprocessor command. The aim off the ##
> preprocessor directive is to build a new name from a template
> argument. But & was never legal as a part of a variable name. So the
> preprocessor say that the result "Foo&" don't qualify a valid variable
> name (token).

Yes, this sounds reasonable. For the  COPY_ACCESS argument I also don't
use ## to add a : to the end.

> "X &" works but I think "X&", as this, should also works since the
> preprocessor should see it as 2 tokens.

## was superfluous, and for a strict compiler it is an error.





More information about the kde-core-devel mailing list