Pimpl copying

Michel Hermier michel.hermier at gmail.com
Sat Jul 15 08:07:21 BST 2006


> --- 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).
"X &" works but I think "X&", as this, should also works since the
preprocessor should see it as 2 tokens.




More information about the kde-core-devel mailing list