Boost logo

Boost :

From: Joel de Guzman (joel_at_[hidden])
Date: 2005-10-12 20:49:43

Eric Niebler wrote:
> Joel de Guzman wrote:
> In "Block Statement", ( you show how to use the
> comma operator to sequence statements. I see problems here, especially
> when calling a function that takes a predicate that isn't the last
> argument. For instance, how would you use Phoenix to create a
> filter_iterator?
> iterator begin, end;
> ...
> boost::make_filter_iterator(arg1 > 5, begin, end);
> // Oops! ---------------------------^
> Isn't that comma going to be Phoenix's overloaded comma?

No. If you want the comma operator to fire, you have to place them
inside parentheses:

     boost::make_filter_iterator((arg1 > 5, blah1, blah2), begin, end);

I remember a very early version of Phoenix named SE (short for
semantic expressions) and Spirit where I used the () operator
instead of the [] operator. For compound expressions, I had
to use the double parens. Example:


Otherwise, C++ will complain.


Joel de Guzman

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