![]() |
BOOST_FOREACH uses some fairly sophisticated techniques that not all compilers support. Depending on how compliant your compiler is, you may not be able to use BOOST_FOREACH in some scenarios. Since BOOST_FOREACH uses Boost.Range, it inherits Boost.Range's portability issues. You can read about those issues in that library's Portability section.
In addition to the demands placed on the compiler by Boost.Range, BOOST_FOREACH places additional demands in order to handle r-value sequences properly. (Recall that an r-value is an unnamed object, so an example of an r-value sequence would be a function that returns a std::vector<> by value.) Compilers vary in their handling of r-values and l-values. To cope with the situation BOOST_FOREACH defines three levels of compliance, described below:
BOOST_FOREACH Compliance Levels
Below are the compilers BOOST_FOREACH has been tested with, and the compliance level you can expect from each.
| Compiler | Compliance Level |
|---|---|
| Visual C++ 7.1 | Level 1 |
| Visual C++ Whidbey Beta | Level 1 |
| Visual C++ 7.0 | Level 2 |
| Visual C++ 6.0 | Level 2 |
| gcc 3.3.3 | Level 0 |
| Intel for Windows 8.0 | Level 1 |
| Intel for Windows 7.0 | Level 2 |
| Comeau 4.3.3 | Level 0 |
Also, if your compiler is one for which the Boost config system defines BOOST_NO_FUNCTION_TEMPLATE_ORDERING, then the compliance level for the BOOST_FOREACH macro is Level 2, the lowest.
| Copyright © 2004 Eric Niebler |