Boost logo

Boost :

From: Gennaro Prota (gennaro_prota_at_[hidden])
Date: 2006-06-26 08:25:02


On Mon, 26 Jun 2006 11:58:30 +0100, "Martin Bonner"
<martin.bonner_at_[hidden]> wrote:

>The basic rule is that you must never have the (pp-)tokens "max" and "("
>one after the other.

Yes.

>If you do, the preprocessor will try to expand the
>max macro.
>
>The solution is to wrap the function name in parens

It's not the only solution, fortunately (the parentheses in general
also prevent ADL). You can use anything different than an open paren
which doesn't change the meaning of the construct after the
preprocessing phase. For instance:

#define DONT_EXPAND_ANY_HOMONYMOUS_MACRO

return [std::]numeric_limits<double>::max
DONT_EXPAND_ANY_HOMONYMOUS_MACRO ();

Of course that's exactly what BOOST_PREVENT_MACRO_SUBSTITUTION is for.
FWIW, I would prefer for it to be named something like
BOOST_GUARD_FROM_FUNCTION_LIKE_MACRO, as it does not apply to
object-like macros.

--Gennaro.


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