Boost logo

Boost Users :

From: Dave Steffen (dgsteffen_at_[hidden])
Date: 2005-05-10 16:39:15


Another question about the to-be-released FOREACH macro, which I find
I am using heavily... (BTW - Thanks Eric for your quick responses, and
for the cool macro!)

The issue is declaring the 'loop variable' for maps. For example,

 vector<int> v;
 ...
 FOREACH (int a, v) { ... } // this compiles
 int b;
 FOREACH (b, v) {...} // this also compiles

However, for maps, the second variation (declaring outside the macro)
doesn't work:

 map<int,int> m;
 ...
 FOREACH (map<int,int>::value_type i, m) {...} // compiles
 map<int,int>::value_type i;
 FOREACH (i, m) {...} // COMPILE ERROR

Specifically, the compiler says

error: non-static const member
` const int std::pair<const int,int>::first',
can't use default assignment operator

(from GCC 3.3.1). Despite my best efforts, I can't figure out what
this error means, or what it's talking about. Anybody else run into
this? Any thoughts?

----------------------------------------------------------------------
Dave Steffen, Ph.D. "The only justification for our concepts and
Software Engineer IV systems of concepts is that they serve to
Numerica Corporation represent the complex of our experiences;
ph (970) 419-8343 x27 beyond this they have no legitimacy."
fax (970) 223-6797 -- Albert Einstein
dgsteffen_at_[hidden]


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