Boost logo

Boost :

From: Stefan Strasser (sstrasser_at_[hidden])
Date: 2005-04-25 16:55:18


michael toksvig schrieb:
>>What is your evaluation of the documentation?
>
>
> describe pitfalls, if any. actually, there is one pitfall:
>
> BOOST_FOREACH(pair<Key, Value> &p, some_map)
>
> does not work, since the preprocessor just can't get over that first comma
>

this could be worked around with C99 variadic macros if available,
something like:

#define _BOOST_FOREACH2(a1,a2,...) BOOST_FOREACH2(a1,a2)
#define _BOOST_FOREACH3(a1,a2,a3,...) BOOST_FOREACH3(a1,a2,a3)
// ...

#define _BOOST_FOREACH(a1,a2,a3,a4,a5,a6,a7,a8,a9,nr,...)
_BOOST_FOREACH##nr(a1,a2,a3,a4,a5,a6,a7,a8,a9)

#define BOOST_FOREACH(...) _BOOST_FOREACH(__VA_ARGS__,9,8,7,6,5,4,3,2,1)

-- 
Stefan Strasser

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