Boost logo

Boost :

From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2006-01-21 16:01:29


 
Alberto Ganesh Barbati wrote:

> this post originates from thread "concatenation of power of
> negative number" in comp.std.c++ (http://tinyurl.com/asn95).
> Consider this file:
>
> ----
> #include <boost/preprocessor/cat.hpp>
> BOOST_PP_CAT(1e, -1)
> ----
>
> According to Paul Mensonides' reply in the thread, it should
> be eventually interpreted as
>
> <1e> ## <-> <1>
>
> thus the pp-number "1e" is concatenated with "-" obtaining
> the pp-number "1e-" and then "1" is appended as a separate
> token. The final result would thus be "1e- 1" (notice the
> blank between "-" and "1").
>
> However, if run into Wave, the program above produces the
> error message:
>
> error: pasting the following two tokens does not give a valid
> preprocessing token: "e" and "-"
>
> Who's right? I'd agree with Paul Mensonides, because "1e" is
> a valid pp token which is to be formed before applying the ##
> operator. But my understanding is quite limited in this area
> so I commit myself to the Gurus.

Paul is right and Wave is wrong. That's a known issue with Wave, it stems
from the fact that Wave currently works on C++ tokens, not pp-tokens as
mandated by the Standard. This will be fixed in the future, when I change
Wave to operate on pp-tokens, rescanning these into C++ tokens after
preprocessing. If you need to preprocess this kind of constructs with Wave,
you may want to use the --variadics command line option, allowing
concatenation of unrelated tokens.

Regards Hartmut


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk