[boost] [preprocessor] PP_CAT with symbols

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[boost] [preprocessor] PP_CAT with symbols

lcaminiti
Hello all,

I just want to confirm that the following:

BOOST_PP_CAT(old_size =, =)

correctly (and always) expands to:

old_size ==

I tested it on MSVC and GCC and it works. Plus from GCC documentation says about ##:

Usually both will be identifiers, or one will be an identifier and the other a preprocessing number. When pasted, they make a longer identifier. This isn't the only valid case. It is also possible to concatenate two numbers (or a number and a name, such as 1.5 and e3) into a number. Also, multi-character operators such as += can be formed by token pasting.
http://gcc.gnu.org/onlinedocs/gcc-3.2.3/cpp/Concatenation.html

I am asking because ## has some limitation (x ## = is not valid, etc) so I want to confirm my understanding is correct.

Thanks a lot.
--Lorenzo
Reply | Threaded
Open this post in threaded view
|

Re: [preprocessor] PP_CAT with symbols

Matt Calabrese
On Sat, Sep 24, 2011 at 1:54 PM, lcaminiti <[hidden email]> wrote:

> I am asking because ## has some limitation (x ## = is not valid, etc) so I
> want to confirm my understanding is correct.
>

Yes, concatenating = with = is valid.

--
-Matt Calabrese

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [preprocessor] PP_CAT with symbols

Mathias Gaunard-2
In reply to this post by lcaminiti
On 24/09/2011 19:54, lcaminiti wrote:

> Hello all,
>
> I just want to confirm that the following:
>
> BOOST_PP_CAT(old_size =, =)
>
> correctly (and always) expands to:
>
> old_size ==
>
> I tested it on MSVC and GCC and it works. Plus from GCC documentation says
> about ##:

## can be used to concatenates two tokens into a single token.


> I am asking because ## has some limitation (x ## = is not valid, etc) so I
> want to confirm my understanding is correct.

x= is not a valid token.
What you want is just the sequence of the two tokens x and =, which is
written as x =


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost