From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2005-03-19 18:47:39
> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]] On Behalf Of Edward Bishop
> I came up with this great macro called IS_UNSIGNED_CHAR() such that
> IS_UNSIGNED_CHAR(unsigned char)
> expands to 1 and
> IS_UNSIGNED_CHAR(hello world)
> or any other input, expands to 0.
Any other identifier or (non-floating-point) pp-number input. You cannot pass
something like '+' because the concatenation yields undefined behavior.
> It almost works, but it gets confused by
> IS_UNSIGNED_CHAR(unsigned world)
> which expands to garbage: BOOST_PP_IIF_I, EQUALS_42_57,
> RETURN_0)((42) world_U_I_O_P));
It doesn't just expand to garbage, it is an error (not enough arguments to a
macro). The problem is that your solution is generating half-open parenthesis
if the input is two identifiers that is not 'unsigned char' but starts with
'unsigned' or ends with 'char'. The macro similarly doesn't work with something
like 'unsigned abc char'.
> Any suggestions? Here is the code:
Are you trying to detect 'unsigned char' specifically, or are you ultimately
trying to compare strings of identifiers (keywords are identifiers here)?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk