Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Portability

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 the Boost.Range Portability section.

In addition to the demands placed on the compiler by Boost.Range, BOOST_FOREACH places additional demands in order to handle rvalue sequences properly. (Recall that an rvalue is an unnamed object, so an example of an rvalue sequence would be a function that returns a std::vector<> by value.) Compilers vary in their handling of rvalues and lvalues. To cope with the situation BOOST_FOREACH defines three levels of compliance, described below:

Table 15.1. BOOST_FOREACH Compliance Levels

Level

Meaning

Level 0

Highest level of compliance
BOOST_FOREACH works with lvalues, rvalues and const-qualified rvalues.

Level 1

Moderate level of compliance
BOOST_FOREACH works with lvalues and plain rvalues, but not const-qualified rvalues.
BOOST_FOREACH_NO_CONST_RVALUE_DETECTION is defined in this case.

Level 2

Lowest level of compliance
BOOST_FOREACH works with lvalues only, not rvalues.
BOOST_FOREACH_NO_RVALUE_DETECTION is defined in this case.


Below are the compilers with which BOOST_FOREACH has been tested, and the compliance level BOOST_FOREACH provides for them.

Table 15.2. Compiler Compliance Level

Compiler

Compliance Level

Visual C++ 8.0

Level 0

Visual C++ 7.1

Level 0

Visual C++ 7.0

Level 2

Visual C++ 6.0

Level 2

gcc 4.0

Level 0

gcc 3.4

Level 0

gcc 3.3

Level 0

mingw 3.4

Level 0

Intel for Linux 9.0

Level 0

Intel for Windows 9.0

Level 0

Intel for Windows 8.0

Level 1

Intel for Windows 7.0

Level 2

Comeau 4.3.3

Level 0

Borland 5.6.4

Level 2

Metrowerks 9.5

Level 1

Metrowerks 9.4

Level 1

SunPro 5.8

Level 2

qcc 3.3

Level 0

tru64cxx 65

Level 2

tru64cxx 71

Level 2



PrevUpHomeNext