1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html> 3<head> 4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 5<title>Portability</title> 6<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> 7<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 8<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> 9<link rel="up" href="../foreach.html" title="Chapter 15. Boost.Foreach"> 10<link rel="prev" href="extensibility.html" title="Extensibility"> 11<link rel="next" href="pitfalls.html" title="Pitfalls"> 12</head> 13<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 14<table cellpadding="2" width="100%"><tr> 15<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> 16<td align="center"><a href="../../../index.html">Home</a></td> 17<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> 18<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 19<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 20<td align="center"><a href="../../../more/index.htm">More</a></td> 21</tr></table> 22<hr> 23<div class="spirit-nav"> 24<a accesskey="p" href="extensibility.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../foreach.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="pitfalls.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> 25</div> 26<div class="section"> 27<div class="titlepage"><div><div><h2 class="title" style="clear: both"> 28<a name="foreach.portability"></a><a class="link" href="portability.html" title="Portability">Portability</a> 29</h2></div></div></div> 30<p> 31 <code class="literal">BOOST_FOREACH</code> uses some fairly sophisticated techniques 32 that not all compilers support. Depending on how compliant your compiler is, 33 you may not be able to use <code class="literal">BOOST_FOREACH</code> in some scenarios. 34 Since <code class="literal">BOOST_FOREACH</code> uses <a href="../../../libs/range/index.html" target="_top">Boost.Range</a>, 35 it inherits <a href="../../../libs/range/index.html" target="_top">Boost.Range</a>'s 36 portability issues. You can read about those issues in the <a href="../../../libs/range/doc/html/range/portability.html" target="_top">Boost.Range 37 Portability</a> section. 38 </p> 39<p> 40 In addition to the demands placed on the compiler by <a href="../../../libs/range/index.html" target="_top">Boost.Range</a>, 41 <code class="literal">BOOST_FOREACH</code> places additional demands in order to handle 42 rvalue sequences properly. (Recall that an rvalue is an unnamed object, so 43 an example of an rvalue sequence would be a function that returns a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><></span></code> by value.) Compilers vary in their 44 handling of rvalues and lvalues. To cope with the situation <code class="literal">BOOST_FOREACH</code> 45 defines three levels of compliance, described below: 46 </p> 47<div class="table"> 48<a name="foreach.portability.t0"></a><p class="title"><b>Table 15.1. BOOST_FOREACH Compliance Levels</b></p> 49<div class="table-contents"><table class="table" summary="BOOST_FOREACH Compliance Levels"> 50<colgroup> 51<col> 52<col> 53</colgroup> 54<thead><tr> 55<th> 56 <p> 57 Level 58 </p> 59 </th> 60<th> 61 <p> 62 Meaning 63 </p> 64 </th> 65</tr></thead> 66<tbody> 67<tr> 68<td> 69 <p> 70 <span class="bold"><strong>Level 0</strong></span> 71 </p> 72 </td> 73<td> 74 <p> 75 <span class="emphasis"><em><span class="underline">Highest level of compliance</span></em></span><br> 76 <code class="literal">BOOST_FOREACH</code> works with lvalues, rvalues and 77 const-qualified rvalues. 78 </p> 79 </td> 80</tr> 81<tr> 82<td> 83 <p> 84 <span class="bold"><strong>Level 1</strong></span> 85 </p> 86 </td> 87<td> 88 <p> 89 <span class="emphasis"><em><span class="underline">Moderate level of compliance</span></em></span><br> 90 <code class="literal">BOOST_FOREACH</code> works with lvalues and plain rvalues, 91 but not const-qualified rvalues.<br> <code class="computeroutput"><span class="identifier">BOOST_FOREACH_NO_CONST_RVALUE_DETECTION</span></code> 92 is defined in this case. 93 </p> 94 </td> 95</tr> 96<tr> 97<td> 98 <p> 99 <span class="bold"><strong>Level 2</strong></span> 100 </p> 101 </td> 102<td> 103 <p> 104 <span class="emphasis"><em><span class="underline">Lowest level of compliance</span></em></span><br> 105 <code class="literal">BOOST_FOREACH</code> works with lvalues only, not rvalues.<br> 106 <code class="computeroutput"><span class="identifier">BOOST_FOREACH_NO_RVALUE_DETECTION</span></code> 107 is defined in this case. 108 </p> 109 </td> 110</tr> 111</tbody> 112</table></div> 113</div> 114<br class="table-break"><p> 115 Below are the compilers with which <code class="literal">BOOST_FOREACH</code> has been 116 tested, and the compliance level <code class="literal">BOOST_FOREACH</code> provides 117 for them. 118 </p> 119<div class="table"> 120<a name="foreach.portability.t1"></a><p class="title"><b>Table 15.2. Compiler Compliance Level</b></p> 121<div class="table-contents"><table class="table" summary="Compiler Compliance Level"> 122<colgroup> 123<col> 124<col> 125</colgroup> 126<thead><tr> 127<th> 128 <p> 129 Compiler 130 </p> 131 </th> 132<th> 133 <p> 134 Compliance Level 135 </p> 136 </th> 137</tr></thead> 138<tbody> 139<tr> 140<td> 141 <p> 142 Visual C++ 8.0 143 </p> 144 </td> 145<td> 146 <p> 147 Level 0 148 </p> 149 </td> 150</tr> 151<tr> 152<td> 153 <p> 154 Visual C++ 7.1 155 </p> 156 </td> 157<td> 158 <p> 159 Level 0 160 </p> 161 </td> 162</tr> 163<tr> 164<td> 165 <p> 166 Visual C++ 7.0 167 </p> 168 </td> 169<td> 170 <p> 171 Level 2 172 </p> 173 </td> 174</tr> 175<tr> 176<td> 177 <p> 178 Visual C++ 6.0 179 </p> 180 </td> 181<td> 182 <p> 183 Level 2 184 </p> 185 </td> 186</tr> 187<tr> 188<td> 189 <p> 190 gcc 4.0 191 </p> 192 </td> 193<td> 194 <p> 195 Level 0 196 </p> 197 </td> 198</tr> 199<tr> 200<td> 201 <p> 202 gcc 3.4 203 </p> 204 </td> 205<td> 206 <p> 207 Level 0 208 </p> 209 </td> 210</tr> 211<tr> 212<td> 213 <p> 214 gcc 3.3 215 </p> 216 </td> 217<td> 218 <p> 219 Level 0 220 </p> 221 </td> 222</tr> 223<tr> 224<td> 225 <p> 226 mingw 3.4 227 </p> 228 </td> 229<td> 230 <p> 231 Level 0 232 </p> 233 </td> 234</tr> 235<tr> 236<td> 237 <p> 238 Intel for Linux 9.0 239 </p> 240 </td> 241<td> 242 <p> 243 Level 0 244 </p> 245 </td> 246</tr> 247<tr> 248<td> 249 <p> 250 Intel for Windows 9.0 251 </p> 252 </td> 253<td> 254 <p> 255 Level 0 256 </p> 257 </td> 258</tr> 259<tr> 260<td> 261 <p> 262 Intel for Windows 8.0 263 </p> 264 </td> 265<td> 266 <p> 267 Level 1 268 </p> 269 </td> 270</tr> 271<tr> 272<td> 273 <p> 274 Intel for Windows 7.0 275 </p> 276 </td> 277<td> 278 <p> 279 Level 2 280 </p> 281 </td> 282</tr> 283<tr> 284<td> 285 <p> 286 Comeau 4.3.3 287 </p> 288 </td> 289<td> 290 <p> 291 Level 0 292 </p> 293 </td> 294</tr> 295<tr> 296<td> 297 <p> 298 Borland 5.6.4 299 </p> 300 </td> 301<td> 302 <p> 303 Level 2 304 </p> 305 </td> 306</tr> 307<tr> 308<td> 309 <p> 310 Metrowerks 9.5 311 </p> 312 </td> 313<td> 314 <p> 315 Level 1 316 </p> 317 </td> 318</tr> 319<tr> 320<td> 321 <p> 322 Metrowerks 9.4 323 </p> 324 </td> 325<td> 326 <p> 327 Level 1 328 </p> 329 </td> 330</tr> 331<tr> 332<td> 333 <p> 334 SunPro 5.8 335 </p> 336 </td> 337<td> 338 <p> 339 Level 2 340 </p> 341 </td> 342</tr> 343<tr> 344<td> 345 <p> 346 qcc 3.3 347 </p> 348 </td> 349<td> 350 <p> 351 Level 0 352 </p> 353 </td> 354</tr> 355<tr> 356<td> 357 <p> 358 tru64cxx 65 359 </p> 360 </td> 361<td> 362 <p> 363 Level 2 364 </p> 365 </td> 366</tr> 367<tr> 368<td> 369 <p> 370 tru64cxx 71 371 </p> 372 </td> 373<td> 374 <p> 375 Level 2 376 </p> 377 </td> 378</tr> 379</tbody> 380</table></div> 381</div> 382<br class="table-break"> 383</div> 384<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 385<td align="left"></td> 386<td align="right"><div class="copyright-footer">Copyright © 2004 Eric Niebler<p> 387 Distributed under the Boost Software License, Version 1.0. (See accompanying 388 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 389 </p> 390</div></td> 391</tr></table> 392<hr> 393<div class="spirit-nav"> 394<a accesskey="p" href="extensibility.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../foreach.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="pitfalls.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> 395</div> 396</body> 397</html> 398