Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost users][tuple] foreach with tuple
From: Matthieu Brucher (matthieu.brucher_at_[hidden])
Date: 2009-08-04 03:02:06


2009/8/4 Oliver Kania <kania.oliver_at_[hidden]>:
> Hello , I have a problem getting boost foreach to work with a vector of
> tuples
> of type tuple<int,int>:
>
> #define foreach BOOST_FOREACH
> ....
> vector<tuple<int,int> > l_listLeftLines;
> ....
> foreach (boost::tuple<int,int>& i_pair, l_listLeftLines)
>     {
>        .....
>     }
>
> The visual studio compiler gives me the following :
>
> 1>d:\projects\software\lib_msvc\ptw2ddatalib20\source\ptwfieldcheckalgorithm.cpp(227)
> : warning C4002: too many actual parameters for macro 'BOOST_FOREACH'
> 1>d:\projects\software\lib_msvc\ptw2ddatalib20\source\ptwfieldcheckalgorithm.cpp(227)
> : error C2143: syntax error : missing ')' before '>'
>
> ..... and a long tail of more errors
>
> best regards,
> Oliver

Hi,

Try with:
foreach ((boost::tuple<int,int>& i_pair), l_listLeftLines)

The issue is that < and > are not delimiters for the macro, so you
have actually 3 parameters if you don't add the parenthesis.

Matthieu

-- 
Information System Engineer, Ph.D.
Website: http://matthieu-brucher.developpez.com/
Blogs: http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn: http://www.linkedin.com/in/matthieubrucher

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net