diff options
author | Chanho Park <chanho61.park@samsung.com> | 2014-12-11 18:55:56 +0900 |
---|---|---|
committer | Chanho Park <chanho61.park@samsung.com> | 2014-12-11 18:55:56 +0900 |
commit | 08c1e93fa36a49f49325a07fe91ff92c964c2b6c (patch) | |
tree | 7a7053ceb8874b28ec4b868d4c49b500008a102e /doc/html/foreach.html | |
parent | bb4dd8289b351fae6b55e303f189127a394a1edd (diff) | |
download | boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.gz boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.bz2 boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.zip |
Imported Upstream version 1.57.0upstream/1.57.0
Diffstat (limited to 'doc/html/foreach.html')
-rw-r--r-- | doc/html/foreach.html | 54 |
1 files changed, 39 insertions, 15 deletions
diff --git a/doc/html/foreach.html b/doc/html/foreach.html index 114dbac944..071ae5a152 100644 --- a/doc/html/foreach.html +++ b/doc/html/foreach.html @@ -1,9 +1,9 @@ <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> -<title>Chapter 8. Boost.Foreach</title> +<title>Chapter 10. Boost.Foreach</title> <link rel="stylesheet" href="../../doc/src/boostbook.css" type="text/css"> -<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<meta name="generator" content="DocBook XSL Stylesheets V1.78.1"> <link rel="home" href="index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> <link rel="up" href="libraries.html" title="Part I. The Boost C++ Libraries (BoostBook Subset)"> <link rel="prev" href="boost/local_time/tz_database.html" title="Type definition tz_database"> @@ -25,7 +25,7 @@ <div class="chapter"> <div class="titlepage"><div> <div><h2 class="title"> -<a name="foreach"></a>Chapter 8. Boost.Foreach</h2></div> +<a name="foreach"></a>Chapter 10. Boost.Foreach</h2></div> <div><div class="author"><h3 class="author"> <span class="firstname">Eric</span> <span class="surname">Niebler</span> </h3></div></div> @@ -39,7 +39,7 @@ </div></div> <div class="toc"> <p><b>Table of Contents</b></p> -<dl> +<dl class="toc"> <dt><span class="section"><a href="foreach.html#foreach.introduction">Introduction</a></span></dt> <dt><span class="section"><a href="foreach/extensibility.html">Extensibility</a></span></dt> <dt><span class="section"><a href="foreach/portability.html">Portability</a></span></dt> @@ -57,7 +57,7 @@ </p></blockquote></div> <h3> <a name="foreach.introduction.h0"></a> - <span><a name="foreach.introduction.what_is__literal_boost_foreach__literal__"></a></span><a class="link" href="foreach.html#foreach.introduction.what_is__literal_boost_foreach__literal__">What + <span class="phrase"><a name="foreach.introduction.what_is__literal_boost_foreach__literal__"></a></span><a class="link" href="foreach.html#foreach.introduction.what_is__literal_boost_foreach__literal__">What is <code class="literal">BOOST_FOREACH</code>?</a> </h3> <p> @@ -83,7 +83,7 @@ </p> <h3> <a name="foreach.introduction.h1"></a> - <span><a name="foreach.introduction.hello__world_"></a></span><a class="link" href="foreach.html#foreach.introduction.hello__world_">Hello, + <span class="phrase"><a name="foreach.introduction.hello__world_"></a></span><a class="link" href="foreach.html#foreach.introduction.hello__world_">Hello, world!</a> </h3> <p> @@ -113,7 +113,7 @@ </pre> <h3> <a name="foreach.introduction.h2"></a> - <span><a name="foreach.introduction.supported_sequence_types"></a></span><a class="link" href="foreach.html#foreach.introduction.supported_sequence_types">Supported + <span class="phrase"><a name="foreach.introduction.supported_sequence_types"></a></span><a class="link" href="foreach.html#foreach.introduction.supported_sequence_types">Supported Sequence Types</a> </h3> <p> @@ -126,7 +126,7 @@ Pass Range Concept</a>. For example, we can use <code class="literal">BOOST_FOREACH</code> with: </p> -<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> <li class="listitem"> STL containers </li> @@ -164,7 +164,7 @@ </p> <h3> <a name="foreach.introduction.h3"></a> - <span><a name="foreach.introduction.examples"></a></span><a class="link" href="foreach.html#foreach.introduction.examples">Examples</a> + <span class="phrase"><a name="foreach.introduction.examples"></a></span><a class="link" href="foreach.html#foreach.introduction.examples">Examples</a> </h3> <p> Below are some examples that demonstrate all the different ways we can use @@ -246,7 +246,7 @@ </p> <h3> <a name="foreach.introduction.h4"></a> - <span><a name="foreach.introduction.making__literal_boost_foreach__literal__prettier"></a></span><a class="link" href="foreach.html#foreach.introduction.making__literal_boost_foreach__literal__prettier">Making + <span class="phrase"><a name="foreach.introduction.making__literal_boost_foreach__literal__prettier"></a></span><a class="link" href="foreach.html#foreach.introduction.making__literal_boost_foreach__literal__prettier">Making <code class="literal">BOOST_FOREACH</code> Prettier</a> </h3> <p> @@ -255,11 +255,11 @@ can get tiresome to look at. That may be true, but <code class="literal">BOOST_FOREACH</code> is merely following the <a href="http://www.boost.org/more/lib_guide.htm" target="_top">Boost Naming Convention</a>. That doesn't mean you're stuck with it, though. - If you would like to use a different identifier (<code class="computeroutput"><span class="identifier">foreach</span></code>, + If you would like to use a different identifier (<code class="computeroutput"><span class="identifier">foreach_</span></code>, perhaps), you can simply do: </p> -<pre class="programlisting"><span class="preprocessor">#define</span> <span class="identifier">foreach</span> <span class="identifier">BOOST_FOREACH</span> -<span class="preprocessor">#define</span> <span class="identifier">reverse_foreach</span> <span class="identifier">BOOST_REVERSE_FOREACH</span> +<pre class="programlisting"><span class="preprocessor">#define</span> <span class="identifier">foreach_</span> <span class="identifier">BOOST_FOREACH</span> +<span class="preprocessor">#define</span> <span class="identifier">foreach_r_</span> <span class="identifier">BOOST_REVERSE_FOREACH</span> </pre> <p> Only do this if you are sure that the identifier you choose will not cause @@ -271,15 +271,39 @@ <th align="left">Note</th> </tr> <tr><td align="left" valign="top"><p> - Do not use <code class="computeroutput"><span class="preprocessor">#define</span> <span class="identifier">foreach</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span><span class="identifier">y</span><span class="special">)</span> <span class="identifier">BOOST_FOREACH</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span><span class="identifier">y</span><span class="special">)</span></code>. This + Do not use <code class="computeroutput"><span class="preprocessor">#define</span> <span class="identifier">foreach_</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span><span class="identifier">y</span><span class="special">)</span> <span class="identifier">BOOST_FOREACH</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span><span class="identifier">y</span><span class="special">)</span></code>. This can be problematic if the arguments are macros themselves. This would result in an additional expansion of these macros. Instead, use the form shown above. </p></td></tr> </table></div> +<p> + Lastly, a word of warning. Lots of folks use a <code class="computeroutput"><span class="identifier">foreach</span></code> + macro as a short form for <code class="computeroutput"><span class="identifier">BOOST_FOREACH</span></code>. + I discourage this. It leads to name conflicts within the <code class="computeroutput"><span class="identifier">BOOST_FOREACH</span></code> + macro itself, where <code class="computeroutput"><span class="identifier">foreach</span></code> + is the name of a namespace. Besides, <code class="computeroutput"><span class="identifier">foreach</span></code> + is a common-enough identifier; even <a href="http://qt.digia.com/" target="_top">Qt</a> + defines it as a macro. If you insist on using <code class="computeroutput"><span class="identifier">foreach</span></code>, + you might try something like this: + </p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">foreach</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">namespace</span> <span class="identifier">boost</span> +<span class="special">{</span> + <span class="comment">// Suggested work-around for https://svn.boost.org/trac/boost/ticket/6131</span> + <span class="keyword">namespace</span> <span class="identifier">BOOST_FOREACH</span> <span class="special">=</span> <span class="identifier">foreach</span><span class="special">;</span> +<span class="special">}</span> + +<span class="preprocessor">#define</span> <span class="identifier">foreach</span> <span class="identifier">BOOST_FOREACH</span> +</pre> +<p> + This will work around <span class="emphasis"><em>some</em></span> of the problems you're likely + to encounter, but not all. Prefer using a different identifier. + </p> </div> </div> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> -<td align="left"><p><small>Last revised: August 15, 2012 at 23:44:05 GMT</small></p></td> +<td align="left"><p><small>Last revised: October 30, 2014 at 10:18:54 GMT</small></p></td> <td align="right"><div class="copyright-footer"></div></td> </tr></table> <hr> |