Boost logo

Boost :

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

Eric Niebler schrieb:
> Stefan Strasser wrote:
>> michael toksvig schrieb:
>>> 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:
> Clever, but there is an ambiguity here. What is the relations of the
> arguments in BOOST_FOREACH2(a1,a2,a3)? Do a1 and a2 together make up the
> loop variable declaration, or do a2 and a3 together form the collection
> expression:
> case 1:
> BOOST_FOREACH( std::pair<int,int> p, some_map )
> case 2:
> BOOST_FOREACH( int i, some_trait<this,that>::some_list() )

right, haven't thought of that.
but I still think the workaround is convenient because
  - case 1 is more common than case 2
  - both cases fail without workaround
  - the user can workaround case 2(parens), but can't case 1(at least,
not easily, without typedef)

> Anyway, I haven't heard of a major C++ compiler supporting C99 varargs.
> Is there one? I don't think we have a config macro for detecting it.

gcc and intel support it by default, como does with --c99
don't know about others, but 3 major ones are a good deal.

Stefan Strasser

Boost list run by bdawes at, gregod at, cpdaniel at, john at