|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r71733 - in sandbox/local/libs/local: doc/html doc/html/boost_local doc/qbk example
From: lorcaminiti_at_[hidden]
Date: 2011-05-04 23:11:31
Author: lcaminiti
Date: 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
New Revision: 71733
URL: http://svn.boost.org/trac/boost/changeset/71733
Log:
Proofread up to Tutorial section.
Text files modified:
sandbox/local/libs/local/doc/html/BOOST_IDENTITY_TYPE.html | 2
sandbox/local/libs/local/doc/html/BOOST_IDENTITY_VALUE.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_BLOCK.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_BLOCK_END.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_BLOCK_TPL.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_CONFIG_COMPLIANT.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_CONFIG_FUNCTION_ARITY_MAX.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_CONFIG_THIS_PARAM_NAME.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT_END.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT_TPL.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_FUNCTION_NAME.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_FUNCTION_PARAMS.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_FUNCTION_PARAMS_TPL.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_TYPEOF.html | 2
sandbox/local/libs/local/doc/html/boost_local/Advanced_Topics.html | 28 ++--
sandbox/local/libs/local/doc/html/boost_local/Getting_Started.html | 35 +++---
sandbox/local/libs/local/doc/html/boost_local/Tutorial.html | 209 ++++++++++++++++++++-------------------
sandbox/local/libs/local/doc/html/index.html | 98 ++++++++++--------
sandbox/local/libs/local/doc/qbk/getting_started.qbk | 23 ++--
sandbox/local/libs/local/doc/qbk/introduction.qbk | 46 ++++----
sandbox/local/libs/local/doc/qbk/tutorial.qbk | 57 +++++----
sandbox/local/libs/local/example/add_block.cpp | 3
sandbox/local/libs/local/example/add_block_va.cpp | 3
sandbox/local/libs/local/example/add_exit.cpp | 4
sandbox/local/libs/local/example/add_exit_va.cpp | 4
sandbox/local/libs/local/example/add_function.cpp | 2
sandbox/local/libs/local/example/add_function_va.cpp | 2
sandbox/local/libs/local/example/add_template.cpp | 1
sandbox/local/libs/local/example/add_template_va.cpp | 1
sandbox/local/libs/local/example/add_this.cpp | 2
sandbox/local/libs/local/example/add_this_va.cpp | 2
sandbox/local/libs/local/example/add_x_y.cpp | 4
sandbox/local/libs/local/example/add_x_y_default.cpp | 2
sandbox/local/libs/local/example/add_x_y_default_va.cpp | 2
sandbox/local/libs/local/example/add_x_y_default_with_va.cpp | 2
sandbox/local/libs/local/example/add_x_y_va.cpp | 4
sandbox/local/libs/local/example/ten.cpp | 2
sandbox/local/libs/local/example/ten_ep.cpp | 2
sandbox/local/libs/local/example/ten_va.cpp | 2
40 files changed, 302 insertions(+), 268 deletions(-)
Modified: sandbox/local/libs/local/doc/html/BOOST_IDENTITY_TYPE.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_IDENTITY_TYPE.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_IDENTITY_TYPE.html 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_IDENTITY_TYPE(parenthesized_type)</pre></div>
<div class="refsect1">
-<a name="id914796"></a><h2>Description</h2>
+<a name="id915089"></a><h2>Description</h2>
<p>This macro expands to an expression that can be passed as a single macro parameter even if it contains commas and that evaluates to the specified type at compile-time (see the <a class="link" href="boost_local/Advanced_Topics.html" title="Advanced Topics"> Advanced Topics</a> section).</p>
<p>For example <code class="computeroutput">BOOST_IDENTITY_TYPE((std::map<int, double>))</code> can be passed as a single macro parameter when instead <code class="computeroutput">std::map<int, double></code> cannot (because it contains a comma not wrapped by round parenthesis so it will be interpreted as two separate macro parameters by the preprocessor).</p>
<p><span class="bold"><strong>Parameters:</strong></span> </p>
Modified: sandbox/local/libs/local/doc/html/BOOST_IDENTITY_VALUE.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_IDENTITY_VALUE.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_IDENTITY_VALUE.html 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_IDENTITY_VALUE(parenthesized_value)</pre></div>
<div class="refsect1">
-<a name="id914937"></a><h2>Description</h2>
+<a name="id915230"></a><h2>Description</h2>
<p>This macro expands to an expression that can be passed as a single macro parameter even if it contains commas and that evaluates to the specified value at run-time (see the <a class="link" href="boost_local/Advanced_Topics.html" title="Advanced Topics"> Advanced Topics</a> section).</p>
<p>For example <code class="computeroutput">BOOST_IDENTITY_VALUE((key_sizeof<int, double>::value))</code> can be passed as a single macro parameter when instead <code class="computeroutput">key_sizeof<int, double>::value</code> cannot (because it contains a comma not wrapped by round parenthesis so it will be interpreted as two separate macro parameters by the preprocessor).</p>
<p><span class="bold"><strong>Parameters:</strong></span> </p>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_BLOCK.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_BLOCK.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_BLOCK.html 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_BLOCK(bindings)</pre></div>
<div class="refsect1">
-<a name="id910895"></a><h2>Description</h2>
+<a name="id911189"></a><h2>Description</h2>
<p>This macro must be used within a declarative context, it must be followed by the local block body code and then by the <code class="computeroutput"><a class="link" href="BOOST_LOCAL_BLOCK_END.html" title="Macro BOOST_LOCAL_BLOCK_END">BOOST_LOCAL_BLOCK_END</a></code> macro (see the Tutorial section): </p>
<pre class="programlisting"> <span class="special">{</span> <span class="comment">// Some declarative context.</span>
<span class="special">...</span>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_BLOCK_END.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_BLOCK_END.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_BLOCK_END.html 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_BLOCK_END</pre></div>
<div class="refsect1">
-<a name="id911633"></a><h2>Description</h2>
+<a name="id911927"></a><h2>Description</h2>
<p>This macro must follow the local block body code <code class="computeroutput">{ ... }</code> as shown in the <code class="computeroutput"><a class="link" href="BOOST_LOCAL_BLOCK.html" title="Macro BOOST_LOCAL_BLOCK">BOOST_LOCAL_BLOCK</a></code> documentation.</p>
<p><span class="bold"><strong>Note:</strong></span> This macro cannot be used multiple times on the same line because it internally uses the line number <code class="computeroutput">__LINE__</code> to generate unique identifiers.</p>
<p><span class="bold"><strong>See:</strong></span> <code class="computeroutput"><a class="link" href="BOOST_LOCAL_BLOCK.html" title="Macro BOOST_LOCAL_BLOCK">BOOST_LOCAL_BLOCK</a></code>, <a class="link" href="boost_local/Tutorial.html" title="Tutorial">Tutorial</a> section. </p>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_BLOCK_TPL.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_BLOCK_TPL.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_BLOCK_TPL.html 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_BLOCK_TPL(bindings)</pre></div>
<div class="refsect1">
-<a name="id911559"></a><h2>Description</h2>
+<a name="id911853"></a><h2>Description</h2>
<p><span class="bold"><strong>See:</strong></span> <code class="computeroutput"><a class="link" href="BOOST_LOCAL_BLOCK.html" title="Macro BOOST_LOCAL_BLOCK">BOOST_LOCAL_BLOCK</a></code>, <a class="link" href="boost_local/Tutorial.html" title="Tutorial">Tutorial</a> section. </p>
</div>
</div>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_CONFIG_COMPLIANT.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_CONFIG_COMPLIANT.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_CONFIG_COMPLIANT.html 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_CONFIG_COMPLIANT</pre></div>
<div class="refsect1">
-<a name="id911800"></a><h2>Description</h2>
+<a name="id912094"></a><h2>Description</h2>
<p>If programmers leave this configuration macro undefined, its default value is to be left not defined.</p>
<p>If this macro is defined, variadic macros and empty macro parameters are not used by this library. Using variadic macros and empty macro parameters allows this library to provide the <span class="emphasis"><em>variadic macro</em></span> and <span class="emphasis"><em>empty macro</em></span> syntaxes which some programmers might find more readable than the <span class="emphasis"><em>sequencing macro</em></span> syntax (see <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_PARAMS.html" title="Macro BOOST_LOCAL_FUNCTION_PARAMS">BOOST_LOCAL_FUNCTION_PARAMS</a></code>, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_BLOCK.html" title="Macro BOOST_LOCAL_BLOCK">BOOST_LOCAL_BLOCK</a></code>, and <code class="computeroutput"><a class="link" href="BOOST_LOCAL_EXIT.html" title="Macro BOOST_LOCAL_EXIT">BOOST_LOCAL_EXIT</a></code>). If this configuration macro is defined then only the sequencing macro syntax is allowed (regardless of whether the compiler supports variadic and e
mpty macros or not).</p>
<p><span class="bold"><strong>Warning:</strong></span> The variadic and empty macro syntaxes are not supported by all C++ compilers so they should be used with care to avoid portability issues (and this configuration macro can be defined to disable them).</p>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_CONFIG_FUNCTION_ARITY_MAX.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_CONFIG_FUNCTION_ARITY_MAX.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_CONFIG_FUNCTION_ARITY_MAX.html 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_CONFIG_FUNCTION_ARITY_MAX</pre></div>
<div class="refsect1">
-<a name="id912005"></a><h2>Description</h2>
+<a name="id912299"></a><h2>Description</h2>
<p>If programmers leave this configuration macro undefined, its default value is <code class="computeroutput">5</code>.</p>
<p>This only refers to the number of local function parameters and not to the number of bound variables in scope (the limit on the number of bound variables is instead the maximum size allowed for a Boost.Preprocessor sequences).</p>
<p><span class="bold"><strong>Warning:</strong></span> Increasing this number will increase compilation time.</p>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_CONFIG_THIS_PARAM_NAME.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_CONFIG_THIS_PARAM_NAME.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_CONFIG_THIS_PARAM_NAME.html 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_CONFIG_THIS_PARAM_NAME</pre></div>
<div class="refsect1">
-<a name="id912100"></a><h2>Description</h2>
+<a name="id912394"></a><h2>Description</h2>
<p>If programmers leave this configuration macro undefined, the default symbol used is <code class="computeroutput">this_</code>.</p>
<p><span class="bold"><strong>Warning:</strong></span> Programmers should not define this macro unless it is absolutely necessary (e.g., to avoid name clashes with another library which cannot be changed). Changing the symbol <code class="computeroutput">this_</code> effectively changes the public API of this library.</p>
<p><span class="bold"><strong>See:</strong></span> <a class="link" href="boost_local/Getting_Started.html" title="Getting Started"> Getting Started</a> section. </p>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT.html 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_EXIT(binding_list)</pre></div>
<div class="refsect1">
-<a name="id912241"></a><h2>Description</h2>
+<a name="id912535"></a><h2>Description</h2>
<p>This macro must be used within a declarative context, it must be followed by the local exit body code and then by the <code class="computeroutput"><a class="link" href="BOOST_LOCAL_EXIT_END.html" title="Macro BOOST_LOCAL_EXIT_END">BOOST_LOCAL_EXIT_END</a></code> macro (see the <a class="link" href="boost_local/Tutorial.html" title="Tutorial">Tutorial</a> section): </p>
<pre class="programlisting"> <span class="special">{</span> <span class="comment">// Some declarative context.</span>
<span class="special">...</span>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT_END.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT_END.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT_END.html 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_EXIT_END</pre></div>
<div class="refsect1">
-<a name="id912992"></a><h2>Description</h2>
+<a name="id913286"></a><h2>Description</h2>
<p>This macro must follow the local exit body code <code class="computeroutput">{ ... }</code> as shown in the <code class="computeroutput"><a class="link" href="BOOST_LOCAL_EXIT.html" title="Macro BOOST_LOCAL_EXIT">BOOST_LOCAL_EXIT</a></code> documentation.</p>
<p><span class="bold"><strong>Note:</strong></span> This macro cannot be used multiple times on the same line because it internally uses the line number <code class="computeroutput">__LINE__</code> to generate unique identifiers.</p>
<p><span class="bold"><strong>See:</strong></span> <code class="computeroutput"><a class="link" href="BOOST_LOCAL_EXIT.html" title="Macro BOOST_LOCAL_EXIT">BOOST_LOCAL_EXIT</a></code>, <a class="link" href="boost_local/Tutorial.html" title="Tutorial">Tutorial</a> section. </p>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT_TPL.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT_TPL.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT_TPL.html 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_EXIT_TPL(binding_list)</pre></div>
<div class="refsect1">
-<a name="id912918"></a><h2>Description</h2>
+<a name="id913212"></a><h2>Description</h2>
<p><span class="bold"><strong>See:</strong></span> <code class="computeroutput"><a class="link" href="BOOST_LOCAL_EXIT.html" title="Macro BOOST_LOCAL_EXIT">BOOST_LOCAL_EXIT</a></code>, <a class="link" href="boost_local/Tutorial.html" title="Tutorial">Tutorial</a> section. </p>
</div>
</div>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_FUNCTION_NAME.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_FUNCTION_NAME.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_FUNCTION_NAME.html 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_FUNCTION_NAME(name)</pre></div>
<div class="refsect1">
-<a name="id914117"></a><h2>Description</h2>
+<a name="id914410"></a><h2>Description</h2>
<p>This macro must follow the local function body code block <code class="computeroutput">{ ... }</code> as shown in the <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_PARAMS.html" title="Macro BOOST_LOCAL_FUNCTION_PARAMS">BOOST_LOCAL_FUNCTION_PARAMS</a></code> documentation.</p>
<p>The local function name can be prefixed by the "keyword" <code class="computeroutput">inline</code>: </p>
<pre class="programlisting"> <span class="special">...</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="keyword">inline</span> <span class="identifier">name</span><span class="special">)</span>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_FUNCTION_PARAMS.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_FUNCTION_PARAMS.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_FUNCTION_PARAMS.html 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_FUNCTION_PARAMS(parameters)</pre></div>
<div class="refsect1">
-<a name="id913159"></a><h2>Description</h2>
+<a name="id913453"></a><h2>Description</h2>
<p>This macro must be used within a declarative context, it must follow the local function result type, it must be followed by the local function body code and then by the <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code> macro (see the <a class="link" href="boost_local/Tutorial.html" title="Tutorial">Tutorial</a> and <a class="link" href="boost_local/Advanced_Topics.html" title="Advanced Topics"> Advanced Topics</a> sections): </p>
<pre class="programlisting"> <span class="special">{</span> <span class="comment">// Some declarative context.</span>
<span class="special">...</span>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_FUNCTION_PARAMS_TPL.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_FUNCTION_PARAMS_TPL.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_FUNCTION_PARAMS_TPL.html 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_FUNCTION_PARAMS_TPL(parameters)</pre></div>
<div class="refsect1">
-<a name="id914042"></a><h2>Description</h2>
+<a name="id914336"></a><h2>Description</h2>
<p><span class="bold"><strong>See:</strong></span> <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_PARAMS.html" title="Macro BOOST_LOCAL_FUNCTION_PARAMS">BOOST_LOCAL_FUNCTION_PARAMS</a></code>, <a class="link" href="boost_local/Tutorial.html" title="Tutorial">Tutorial</a> section. </p>
</div>
</div>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_TYPEOF.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_TYPEOF.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_TYPEOF.html 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_TYPEOF(bound_variable_name)</pre></div>
<div class="refsect1">
-<a name="id914468"></a><h2>Description</h2>
+<a name="id914761"></a><h2>Description</h2>
<p>The type is fully qualified in that it contains the extra constant and reference qualifiers when they are specified for binding by constant and by reference. For example, if a variable named <code class="computeroutput">t</code> of type <code class="computeroutput">T</code> is: </p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>Bound by value using <code class="computeroutput">bind t</code> then <code class="computeroutput">BOOST_LOCAL_TYPEOF(t)</code> is <code class="computeroutput">T</code>. </p></li>
Modified: sandbox/local/libs/local/doc/html/boost_local/Advanced_Topics.html
==============================================================================
--- sandbox/local/libs/local/doc/html/boost_local/Advanced_Topics.html (original)
+++ sandbox/local/libs/local/doc/html/boost_local/Advanced_Topics.html 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -84,7 +84,7 @@
<p>
In addition, local function parameter types cannot start with non-alphanumeric
symbols (alphanumeric symbols are <code class="computeroutput"><span class="identifier">A</span><span class="special">-</span><span class="identifier">Z</span></code>, <code class="computeroutput"><span class="identifier">a</span><span class="special">-</span><span class="identifier">z</span></code>,
- and <code class="computeroutput"><span class="number">0</span><span class="special">-</span><span class="number">9</span></code>). <sup>[<a name="id881360" href="#ftn.id881360" class="footnote">14</a>]</sup> The library will generate (cryptic) preprocessor errors if a
+ and <code class="computeroutput"><span class="number">0</span><span class="special">-</span><span class="number">9</span></code>). <sup>[<a name="id881643" href="#ftn.id881643" class="footnote">16</a>]</sup> The library will generate (cryptic) preprocessor errors if a
parameter type starts with a non-alphanumeric symbol.
</p>
<p>
@@ -207,7 +207,7 @@
<li class="listitem">
Parenthesis to wrap the type expression (and therefore any commas <code class="computeroutput"><span class="special">,</span></code> that it contains) passed as parameter
to the <code class="computeroutput"><a class="link" href="../BOOST_IDENTITY_TYPE.html" title="Macro BOOST_IDENTITY_TYPE">BOOST_IDENTITY_TYPE</a></code>
- macro. <sup>[<a name="id882720" href="#ftn.id882720" class="footnote">15</a>]</sup>
+ macro. <sup>[<a name="id883003" href="#ftn.id883003" class="footnote">17</a>]</sup>
</li>
</ol></div>
<p>
@@ -408,7 +408,7 @@
</p></td></tr>
</table></div>
<p>
- Consider the following complete example: <sup>[<a name="id884024" href="#ftn.id884024" class="footnote">16</a>]</sup>
+ Consider the following complete example: <sup>[<a name="id884308" href="#ftn.id884308" class="footnote">18</a>]</sup>
</p>
<div class="informaltable"><table class="table">
<colgroup>
@@ -1253,7 +1253,7 @@
implementations that use local functor classes (see the <a class="link" href="Alternatives.html" title="Appendix: Alternatives">Alternatives</a>
section). However, inlined local functions have the limitation that they
cannot be assigned to other functors (like <code class="computeroutput">boost::function</code>)
- and they cannot be passed as template parameters <sup>[<a name="id901740" href="#ftn.id901740" class="footnote">17</a>]</sup>.
+ and they cannot be passed as template parameters <sup>[<a name="id902028" href="#ftn.id902028" class="footnote">19</a>]</sup>.
</p>
<p>
On C++0x compilers, <code class="computeroutput"><span class="keyword">inline</span></code>
@@ -1869,7 +1869,7 @@
<td>
<p>
This is not supported because local functions are not member functions.
- <sup>[<a name="id909393" href="#ftn.id909393" class="footnote">a</a>]</sup>
+ <sup>[<a name="id909687" href="#ftn.id909687" class="footnote">a</a>]</sup>
</p>
</td>
</tr>
@@ -1968,7 +1968,7 @@
</td>
</tr>
</tbody>
-<tbody class="footnotes"><tr><td colspan="3"><div class="footnote"><p><sup>[<a id="ftn.id909393" href="#id909393" class="para">a</a>] </sup>
+<tbody class="footnotes"><tr><td colspan="3"><div class="footnote"><p><sup>[<a id="ftn.id909687" href="#id909687" class="para">a</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> In theory, it would
be possible for a local functor class to inherit from another
local functor class. The parenthesized syntax could be extended
@@ -1989,7 +1989,7 @@
It is not possible to overload local functions. Declaring multiple local
functions with the same name within the same enclosing scope generates a
compile-time error (even if the different declarations specify different
- parameters). <sup>[<a name="id909774" href="#ftn.id909774" class="footnote">18</a>]</sup>
+ parameters). <sup>[<a name="id910067" href="#ftn.id910067" class="footnote">20</a>]</sup>
</p>
<p>
For example, the following code will <span class="bold"><strong>not</strong></span>
@@ -2013,7 +2013,7 @@
</h6>
<p>
Local functions cannot be operators. Naming a local function <code class="computeroutput"><span class="keyword">operator</span><span class="special">...</span></code>
- will generate a compile-time error. <sup>[<a name="id910124" href="#ftn.id910124" class="footnote">19</a>]</sup>
+ will generate a compile-time error. <sup>[<a name="id910417" href="#ftn.id910417" class="footnote">21</a>]</sup>
</p>
<p>
For example, the following code will <span class="bold"><strong>not</strong></span>
@@ -2060,21 +2060,21 @@
</div>
<div class="footnotes">
<br><hr width="100" align="left">
-<div class="footnote"><p><sup>[<a id="ftn.id881360" href="#id881360" class="para">14</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id881643" href="#id881643" class="para">16</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> This limitation derives from
the fact that <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_PARAMS.html" title="Macro BOOST_LOCAL_FUNCTION_PARAMS">BOOST_LOCAL_FUNCTION_PARAMS</a></code>
uses preprocessor token concatenation to inspect the parameter type token
to see if the token is a parameter or a bound variable. The C++ preprocessor
does not allow to concatenate non-alphanumeric tokens.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id882720" href="#id882720" class="para">15</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id883003" href="#id883003" class="para">17</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> Using variadic macros,
this extra set of parenthesis could be eliminated requiring only the
parenthesis to invoke the <code class="computeroutput"><a class="link" href="../BOOST_IDENTITY_TYPE.html" title="Macro BOOST_IDENTITY_TYPE">BOOST_IDENTITY_TYPE</a></code>
macro. However, this feature is currently not implemented and the double
parenthesis are always needed when invoking this macro.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id884024" href="#id884024" class="para">16</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id884308" href="#id884308" class="para">18</a>] </sup>
The authors recognize that the use of the <span class="emphasis"><em>identity macros</em></span>
adds extra parenthesis to the already significant number of parenthesis
required by the sequencing macro syntax. However, macro parameters usually
@@ -2082,7 +2082,7 @@
(unless template metaprogramming is being used) so this is usually not
a problem.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id901740" href="#id901740" class="para">17</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id902028" href="#id902028" class="para">19</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> This library uses an indirect
function call via a function pointer in order to pass the local function
as a template parameter (see the <a class="link" href="Implementation.html" title="Appendix: Implementation">Implementation</a>
@@ -2096,14 +2096,14 @@
be inlined on C++0x compilers (even when the local function is not declared
inlined).
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id909774" href="#id909774" class="para">18</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id910067" href="#id910067" class="para">20</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> This is because a local function
is a functor object declared as a local variable within the enclosing scope.
Therefore, declaring two local functions with the same name within the
same enclosing scope declares two local variables with the same name within
the same scope and that is not allowed in C++.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id910124" href="#id910124" class="para">19</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id910417" href="#id910417" class="para">21</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> This is the because a local
function name must be a valid local variable name (the local variable to
hold the local functor object) and operators cannot be used as local variable
Modified: sandbox/local/libs/local/doc/html/boost_local/Getting_Started.html
==============================================================================
--- sandbox/local/libs/local/doc/html/boost_local/Getting_Started.html (original)
+++ sandbox/local/libs/local/doc/html/boost_local/Getting_Started.html 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -50,12 +50,12 @@
sections. The <a class="link" href="Advanced_Topics.html" title="Advanced Topics">Advanced Topics</a>
and Reference sections can be consulted
at a later point to gain a more advanced knowledge of the library. All the
- other sections of this documentation are for reference only.
+ other sections of this documentation are optional.
</p>
<p>
- Some footnotes are marked by the word "<span class="bold"><strong>Rationale</strong></span>"
- because they explain reasons behind decisions made during the design and
- implementation of this library.
+ Some footnotes are marked by the word "<span class="bold"><strong>Rationale</strong></span>".
+ They explain reasons behind decisions made during the design and implementation
+ of this library.
</p>
</div>
<div class="section">
@@ -67,21 +67,22 @@
The implementation of this library uses preprocessor and template metaprogramming
(as supported by Boost.Preprocessor
and Boost.MPL),
- templates with partial specializations and function pointers (to support
- an interface similar to the one of Boost.Function).
+ templates with partial specializations and function pointers (similarly to
+ Boost.Function).
As a consequence, this library is fairly demanding on compilers' compliance
with the ISO C++ standard. At present, this library has been successfully
compiled and tested on the following compilers and platforms:
</p>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
- GCC 4.2.4 on Ubuntu Linux.
+ GNU Compiler Collection (GCC) 4.5.1 (with and without C++0x features
+ enabled) on Ubuntu Linux 10.
</li>
<li class="listitem">
- GCC 3.4.4 on Cygwin.
+ GCC 4.3.4 on Cygwin.
</li>
<li class="listitem">
- Miscrosoft Visual Studio 8.0 on Windows XP.
+ Miscrosoft Visual Studio Compiler (MSVC) 8.0 on Windows XP.
</li>
</ol></div>
<p>
@@ -117,11 +118,11 @@
<code class="computeroutput"><a class="link" href="../reference.html#header.boost.local.block_hpp" title="Header <boost/local/block.hpp>">boost/local/block.hpp</a></code> <span class="emphasis"><em>local blocks</em></span>
<code class="computeroutput"><a class="link" href="../reference.html#header.boost.local.exit_hpp" title="Header <boost/local/exit.hpp>">boost/local/exit.hpp</a></code> <span class="emphasis"><em>local exits</em></span>
<code class="computeroutput"><a class="link" href="../reference.html#header.boost.local.typeof_hpp" title="Header <boost/local/typeof.hpp>">boost/local/typeof.hpp</a></code> <span class="emphasis"><em>bound variable type deduction</em></span>
-<code class="computeroutput"><a class="link" href="../reference.html#header.boost.local.config_hpp" title="Header <boost/local/config.hpp>">boost/local/config.hpp</a></code> <span class="emphasis"><em>configuration macros</em></span>
+<code class="computeroutput"><a class="link" href="../reference.html#header.boost.local.config_hpp" title="Header <boost/local/config.hpp>">boost/local/config.hpp</a></code> <span class="emphasis"><em>library configuration macros</em></span>
</pre>
<p>
- The following symbols are part of the library private API, they are not documented,
- and they should not be directly used by programmers: <sup>[<a name="id866097" href="#ftn.id866097" class="footnote">1</a>]</sup>
+ The followings are part of the library private API, they are not documented,
+ and they should not be directly used by programmers: <sup>[<a name="id866165" href="#ftn.id866165" class="footnote">2</a>]</sup>
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
@@ -152,24 +153,24 @@
it.
</p>
<p>
- All configuration macros have names prefixed by <code class="computeroutput"><span class="identifier">BOOST_LOCAL_CONFIG_</span><span class="special">...</span></code> (see Reference
+ All configuration macros have names prefixed by <code class="computeroutput"><span class="identifier">BOOST_LOCAL_CONFIG_</span><span class="special">...</span></code> (see the Reference
section). It is strongly recommended not to change the library configuration
macro definitions unless strictly necessary.
</p>
</div>
<div class="footnotes">
<br><hr width="100" align="left">
-<div class="footnote"><p><sup>[<a id="ftn.id866097" href="#id866097" class="para">1</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id866165" href="#id866165" class="para">2</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> This library concatenates symbols
specified by the programmers (e.g., the local function name) with other
symbols (e.g., special prefixes or preprocessor line numbers) to make internal
symbols with unique names to avoid name clashes. These symbols are separated
by the letter "<code class="computeroutput"><span class="identifier">X</span></code>"
- when they are concatenated so they can be read more easily while debugging
- the library. The underscore character "<code class="computeroutput"><span class="identifier">_</span></code>"
+ when they are concatenated so they read more easily during debugging. The
+ underscore character "<code class="computeroutput"><span class="identifier">_</span></code>"
could not be used instead of the letter "<code class="computeroutput"><span class="identifier">X</span></code>"
because if the original symbols already contained a leading or trailing
- underscore, the concatenation would result in a symbol with double underscores
+ underscore, the concatenation could result in a symbol with double underscores
"<code class="computeroutput"><span class="identifier">__</span></code>" which is
reserved by the C++ standard.
</p></div>
Modified: sandbox/local/libs/local/doc/html/boost_local/Tutorial.html
==============================================================================
--- sandbox/local/libs/local/doc/html/boost_local/Tutorial.html (original)
+++ sandbox/local/libs/local/doc/html/boost_local/Tutorial.html 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -115,12 +115,12 @@
<span class="special">...</span> <span class="special">}</span></code>
using the usual C++ syntax. The body is specified outside any of the macros
so eventual compiler error messages and related line numbers retain their
- usual meaning. <sup>[<a name="id866792" href="#ftn.id866792" class="footnote">2</a>]</sup>
+ usual meaning and format. <sup>[<a name="id866866" href="#ftn.id866866" class="footnote">3</a>]</sup>
</p>
<p>
The macro <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code>
is used to end the local function definition and to specify the local function
- name. <sup>[<a name="id866828" href="#ftn.id866828" class="footnote">3</a>]</sup>
+ name. <sup>[<a name="id866902" href="#ftn.id866902" class="footnote">4</a>]</sup>
</p>
<p>
For example, let's program a local function named <code class="computeroutput"><span class="identifier">add</span></code>
@@ -155,11 +155,11 @@
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> <span class="special">{</span>
- <span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">y</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">y</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Local function.</span>
<span class="keyword">return</span> <span class="identifier">x</span> <span class="special">+</span> <span class="identifier">y</span><span class="special">;</span>
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">add</span><span class="special">)</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">add</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="number">2</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">add</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="number">2</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// Call local function.</span>
<span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
<span class="special">}</span>
</pre>
@@ -174,11 +174,11 @@
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> <span class="special">{</span>
- <span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS</span><span class="special">(</span> <span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">(</span><span class="keyword">int</span> <span class="identifier">y</span><span class="special">)</span> <span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS</span><span class="special">(</span> <span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">(</span><span class="keyword">int</span> <span class="identifier">y</span><span class="special">)</span> <span class="special">)</span> <span class="special">{</span> <span class="comment">// Local function.</span>
<span class="keyword">return</span> <span class="identifier">x</span> <span class="special">+</span> <span class="identifier">y</span><span class="special">;</span>
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">add</span><span class="special">)</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">add</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="number">2</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">add</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="number">2</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// Call local function.</span>
<span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
<span class="special">}</span>
</pre>
@@ -302,7 +302,7 @@
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> <span class="special">{</span>
- <span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS</span><span class="special">()</span> <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS</span><span class="special">()</span> <span class="special">{</span> <span class="comment">// No parameter.</span>
<span class="keyword">return</span> <span class="number">10</span><span class="special">;</span>
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">ten</span><span class="special">)</span>
@@ -321,7 +321,7 @@
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> <span class="special">{</span>
- <span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// No parameter.</span>
<span class="keyword">return</span> <span class="number">10</span><span class="special">;</span>
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">ten</span><span class="special">)</span>
@@ -340,7 +340,7 @@
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> <span class="special">{</span>
- <span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS</span><span class="special">(</span> <span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS</span><span class="special">(</span> <span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">)</span> <span class="special">{</span> <span class="comment">// No parameter.</span>
<span class="keyword">return</span> <span class="number">10</span><span class="special">;</span>
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">ten</span><span class="special">)</span>
@@ -366,7 +366,7 @@
This library also allows to specify default values for the local function
parameters. However, the usual C++ syntax for default parameters that uses
the assignment symbol <code class="computeroutput"><span class="special">=</span></code> cannot
- be used. <sup>[<a name="id868853" href="#ftn.id868853" class="footnote">4</a>]</sup> The keyword <code class="computeroutput"><span class="keyword">default</span></code>
+ be used. <sup>[<a name="id868966" href="#ftn.id868966" class="footnote">5</a>]</sup> The keyword <code class="computeroutput"><span class="keyword">default</span></code>
is used instead:
</p>
<div class="informaltable"><table class="table">
@@ -402,7 +402,8 @@
</tr></tbody>
</table></div>
<p>
- For example, let's assume that the we want to program a local function <code class="computeroutput"><span class="identifier">add</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span> <span class="identifier">y</span><span class="special">)</span></code>
+ For example, let's program a local function <code class="computeroutput"><span class="identifier">add</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span>
+ <span class="identifier">y</span><span class="special">)</span></code>
similar to the one programmed before but where the second parameter <code class="computeroutput"><span class="identifier">y</span></code> is optional and has a default value of
<code class="computeroutput"><span class="number">2</span></code>:
</p>
@@ -432,7 +433,7 @@
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> <span class="special">{</span>
- <span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">y</span><span class="special">,</span> <span class="keyword">default</span> <span class="number">2</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">y</span><span class="special">,</span> <span class="keyword">default</span> <span class="number">2</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Default.</span>
<span class="keyword">return</span> <span class="identifier">x</span> <span class="special">+</span> <span class="identifier">y</span><span class="special">;</span>
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">add</span><span class="special">)</span>
@@ -451,7 +452,7 @@
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> <span class="special">{</span>
- <span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS</span><span class="special">(</span> <span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">(</span><span class="keyword">int</span> <span class="identifier">y</span><span class="special">)(</span><span class="keyword">default</span> <span class="number">2</span><span class="special">)</span> <span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS</span><span class="special">(</span> <span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">(</span><span class="keyword">int</span> <span class="identifier">y</span><span class="special">)(</span><span class="keyword">default</span> <span class="number">2</span><span class="special">)</span> <span class="special">)</span> <span class="special">{</span> <span class="comment">// Default.</span>
<span class="keyword">return</span> <span class="identifier">x</span> <span class="special">+</span> <span class="identifier">y</span><span class="special">;</span>
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">add</span><span class="special">)</span>
@@ -465,9 +466,8 @@
</tr></tbody>
</table></div>
<p>
- If this variadic macro syntax seems strange, programmers could define a
- <code class="computeroutput"><span class="identifier">WITH_DEFAULT</span></code> macro similar
- to the following if they think it improves readability:
+ If this variadic macro syntax seems strange, programmers can define a <code class="computeroutput"><span class="identifier">WITH_DEFAULT</span></code> macro similar to the following
+ (if they think that improves readability):
</p>
<div class="informaltable"><table class="table">
<colgroup><col></colgroup>
@@ -486,7 +486,7 @@
<span class="preprocessor">#define</span> <span class="identifier">WITH_DEFAULT</span> <span class="special">,</span> <span class="keyword">default</span>
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> <span class="special">{</span>
- <span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">y</span> <span class="identifier">WITH_DEFAULT</span> <span class="number">2</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">y</span> <span class="identifier">WITH_DEFAULT</span> <span class="number">2</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Default.</span>
<span class="keyword">return</span> <span class="identifier">x</span> <span class="special">+</span> <span class="identifier">y</span><span class="special">;</span>
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">add</span><span class="special">)</span>
@@ -508,7 +508,7 @@
variables, the object <code class="computeroutput"><span class="keyword">this</span></code>,
etc) can be bound to a local function declaration. The types of bound variables
are automatically deduced by this library using Boost.Typeof.
- <sup>[<a name="id870214" href="#ftn.id870214" class="footnote">5</a>]</sup>
+ <sup>[<a name="id870490" href="#ftn.id870490" class="footnote">6</a>]</sup>
</p>
<div class="important"><table border="0" summary="Important">
<tr>
@@ -525,13 +525,13 @@
</table></div>
<p>
This library introduces the new "keyword" <code class="computeroutput"><span class="identifier">bind</span></code>
- <sup>[<a name="id870296" href="#ftn.id870296" class="footnote">6</a>]</sup> which is used in place of the parameter type to specify the name
+ <sup>[<a name="id870572" href="#ftn.id870572" class="footnote">7</a>]</sup> which is used in place of the parameter type to specify the name
of a variable in scope to bind. The variable can be bound by value:
</p>
<pre class="programlisting"><span class="identifier">bind</span> <span class="emphasis"><em>variable-name</em></span> <span class="comment">// Bind by value.</span>
</pre>
<p>
- Or by reference if the variable name is prefixed by <code class="computeroutput"><span class="special">&</span></code>:
+ Or by reference prefixing the variable name with <code class="computeroutput"><span class="special">&</span></code>:
</p>
<pre class="programlisting"><span class="identifier">bind</span><span class="special">&</span> <span class="emphasis"><em>variable-name</em></span> <span class="comment">// Bind by reference.</span>
</pre>
@@ -540,7 +540,7 @@
can be prefixed by <code class="computeroutput"><span class="keyword">const</span></code> to
bind the variable by constant value:
</p>
-<pre class="programlisting"><span class="keyword">const</span> <span class="identifier">bind</span> <span class="emphasis"><em>variable-name</em></span> <span class="comment">// Bind by constant value.</span>
+<pre class="programlisting"><span class="keyword">const</span> <span class="identifier">bind</span> <span class="emphasis"><em>variable-name</em></span> <span class="comment">// Bind by value.</span>
</pre>
<p>
Or by constant reference:
@@ -548,15 +548,15 @@
<pre class="programlisting"><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">&</span> <span class="emphasis"><em>variable-name</em></span> <span class="comment">// Bind by constant value.</span>
</pre>
<p>
- Note that when <code class="computeroutput"><span class="keyword">const</span></code> is used,
- it must always precede <code class="computeroutput"><span class="identifier">bind</span></code>.
+ (Note that when <code class="computeroutput"><span class="keyword">const</span></code> is used,
+ it must always precede <code class="computeroutput"><span class="identifier">bind</span></code>.)
</p>
<p>
If a variable is bound by value, then a copy of the variable value is taken
at the point of the local function declaration. If a variable is bound by
reference instead, the variable will refer to the value it has at the point
of the local function call. Furthermore, it is the programmers' responsibility
- to ensure that variables bound by reference survive the scope of declaration
+ to ensure that variables bound by reference survive the declaration scope
of the local function otherwise the bound references will be invalid causing
run-time errors (in other words, the usual care in using C++ references must
be taken for variables bound by reference).
@@ -564,15 +564,14 @@
<p>
The type of bound variables is automatically deduced and it is the exact
same type used to declare such variables in the enclosing scope. Therefore,
- if a bound variable is declared constant using the <code class="computeroutput"><span class="keyword">const</span></code>
- qualifier in the enclosing scope then it will be always bound by constant
- value or reference even if <code class="computeroutput"><span class="keyword">const</span></code>
+ if a bound variable is declared constant, using the <code class="computeroutput"><span class="keyword">const</span></code>
+ qualifier in the enclosing scope, then it will be always bound by constant
+ value or constant reference even if <code class="computeroutput"><span class="keyword">const</span></code>
is not repeated by the local function binding. On the other hand, if a bound
- variable was not declared constant by enclosing scope then it will not be
- bound as constant unless constant binding is forced using <code class="computeroutput"><span class="keyword">const</span>
- <span class="identifier">bind</span> <span class="special">...</span></code>
- (note that binding by constant reference is not supported by <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++0x
- lambda</a> functions). <sup>[<a name="id870866" href="#ftn.id870866" class="footnote">7</a>]</sup> As with passing parameters to usual C++ functions, programmers
+ variable was not declared constant in the enclosing scope then it will not
+ be bound as constant unless constant binding is forced using <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">bind</span> <span class="special">...</span></code> (note that binding by constant reference
+ is not supported by <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++0x
+ lambda</a> functions but it is supported by this library). <sup>[<a name="id870878" href="#ftn.id870878" class="footnote">8</a>]</sup> As with passing parameters to usual C++ functions, programmers
might want to bind variables of complex types by (constant) reference instead
than by value to avoid expensive copy operations when these variables are
bound to a local function.
@@ -614,7 +613,7 @@
<span class="keyword">int</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span>
<span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS</span><span class="special">(</span><span class="keyword">double</span> <span class="identifier">num</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">factor</span><span class="special">,</span>
- <span class="identifier">bind</span><span class="special">&</span> <span class="identifier">sum</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">bind</span><span class="special">&</span> <span class="identifier">sum</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Bind `factor` and `sum`.</span>
<span class="identifier">sum</span> <span class="special">+=</span> <span class="identifier">factor</span> <span class="special">*</span> <span class="identifier">num</span><span class="special">;</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Summed: "</span> <span class="special"><<</span> <span class="identifier">sum</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">add</span><span class="special">)</span>
@@ -638,7 +637,7 @@
<span class="keyword">int</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span>
<span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS</span><span class="special">(</span> <span class="special">(</span><span class="keyword">double</span> <span class="identifier">num</span><span class="special">)</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">factor</span><span class="special">)</span>
- <span class="special">(</span><span class="identifier">bind</span><span class="special">&</span> <span class="identifier">sum</span><span class="special">)</span> <span class="special">)</span> <span class="special">{</span>
+ <span class="special">(</span><span class="identifier">bind</span><span class="special">&</span> <span class="identifier">sum</span><span class="special">)</span> <span class="special">)</span> <span class="special">{</span> <span class="comment">// Bind `factor` and `sum`.</span>
<span class="identifier">sum</span> <span class="special">+=</span> <span class="identifier">factor</span> <span class="special">*</span> <span class="identifier">num</span><span class="special">;</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Summed: "</span> <span class="special"><<</span> <span class="identifier">sum</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">add</span><span class="special">)</span>
@@ -661,9 +660,9 @@
It is also possible to bind the object <code class="computeroutput"><span class="keyword">this</span></code>
when it is in scope (e.g., from an enclosing member function). This is done
by using <code class="computeroutput"><span class="keyword">this</span></code> as the name of
- the variable to bind and by using the special symbol <code class="computeroutput"><span class="identifier">this_</span></code>
- (instead of <code class="computeroutput"><span class="keyword">this</span></code>) to access
- the object within the local function body.
+ the variable to bind in the local function declaration and by using the special
+ symbol <code class="computeroutput"><span class="identifier">this_</span></code> <sup>[<a name="id871947" href="#ftn.id871947" class="footnote">9</a>]</sup> (instead of <code class="computeroutput"><span class="keyword">this</span></code>)
+ to access the object within the local function body.
</p>
<p>
The object <code class="computeroutput"><span class="keyword">this</span></code> can be bound
@@ -705,18 +704,18 @@
<p>
When the object <code class="computeroutput"><span class="keyword">this</span></code> is bound
to a local function, the local function body must use the special symbol
- <code class="computeroutput"><span class="identifier">this_</span></code> (instead of <code class="computeroutput"><span class="keyword">this</span></code>) to access the bound object. <sup>[<a name="id872045" href="#ftn.id872045" class="footnote">8</a>]</sup>
+ <code class="computeroutput"><span class="identifier">this_</span></code> (instead of <code class="computeroutput"><span class="keyword">this</span></code>) to access the bound object. <sup>[<a name="id872256" href="#ftn.id872256" class="footnote">10</a>]</sup>
</p>
<p>
Unfortunately, mistakenly using <code class="computeroutput"><span class="keyword">this</span></code>
within the local function body instead of <code class="computeroutput"><span class="identifier">this_</span></code>
- will not necessarily generate a compile-time error. <sup>[<a name="id872170" href="#ftn.id872170" class="footnote">9</a>]</sup> Programmers are responsible to make sure that <code class="computeroutput"><span class="keyword">this</span></code> is never used within a local function
+ will not necessarily generate a compile-time error. <sup>[<a name="id872349" href="#ftn.id872349" class="footnote">11</a>]</sup> Programmers are responsible to make sure that <code class="computeroutput"><span class="keyword">this</span></code> is never used within a local function
body which should only use the special symbol <code class="computeroutput"><span class="identifier">this_</span></code>.
</p>
</td></tr>
</table></div>
<p>
- For example, let's rewrite a local function <code class="computeroutput"><span class="identifier">add</span></code>
+ For example, let's program a local function <code class="computeroutput"><span class="identifier">add</span></code>
similar to the one in the example from the <a class="link" href="../index.html#boost_local.Introduction" title="Introduction">Introduction</a>
section but using a member function to illustrate how to bind the object
<code class="computeroutput"><span class="keyword">this</span></code>:
@@ -757,7 +756,7 @@
<span class="keyword">double</span> <span class="identifier">sum</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">double</span><span class="special">>&</span> <span class="identifier">nums</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">int</span><span class="special">&</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">)</span> <span class="special">{</span>
<span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS</span><span class="special">(</span><span class="keyword">double</span> <span class="identifier">num</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">factor</span><span class="special">,</span>
- <span class="identifier">bind</span> <span class="keyword">this</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">bind</span> <span class="keyword">this</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Bind `this`.</span>
<span class="identifier">this_</span><span class="special">-></span><span class="identifier">sum_</span> <span class="special">+=</span> <span class="identifier">factor</span> <span class="special">*</span> <span class="identifier">num</span><span class="special">;</span> <span class="comment">// Use `this_` instead of `this`.</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Summed: "</span> <span class="special"><<</span> <span class="identifier">this_</span><span class="special">-></span><span class="identifier">sum_</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">add</span><span class="special">)</span>
@@ -811,7 +810,7 @@
<span class="keyword">double</span> <span class="identifier">sum</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">double</span><span class="special">>&</span> <span class="identifier">nums</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">int</span><span class="special">&</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">)</span> <span class="special">{</span>
<span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS</span><span class="special">(</span> <span class="special">(</span><span class="keyword">double</span> <span class="identifier">num</span><span class="special">)</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">factor</span><span class="special">)</span>
- <span class="special">(</span><span class="identifier">bind</span> <span class="keyword">this</span><span class="special">)</span> <span class="special">)</span> <span class="special">{</span>
+ <span class="special">(</span><span class="identifier">bind</span> <span class="keyword">this</span><span class="special">)</span> <span class="special">)</span> <span class="special">{</span> <span class="comment">// Bind `this`.</span>
<span class="identifier">this_</span><span class="special">-></span><span class="identifier">sum_</span> <span class="special">+=</span> <span class="identifier">factor</span> <span class="special">*</span> <span class="identifier">num</span><span class="special">;</span> <span class="comment">// Use `this_` instead of `this`.</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Summed: "</span> <span class="special"><<</span> <span class="identifier">this_</span><span class="special">-></span><span class="identifier">sum_</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">add</span><span class="special">)</span>
@@ -878,7 +877,7 @@
are accessible from within the local block body. Following the same syntax
used for local functions, <code class="literal"><span class="emphasis"><em>bindings</em></span></code>
can either be empty (using <code class="computeroutput"><span class="special">(</span><span class="keyword">void</span><span class="special">)</span></code>, <code class="computeroutput"><span class="keyword">void</span></code>, or an empty macro parameter depending
- on your compiler extensions, see <a class="link" href="Tutorial.html#boost_local.Tutorial.Empty_Parameters" title="Empty Parameters">Empty
+ on your compiler, see <a class="link" href="Tutorial.html#boost_local.Tutorial.Empty_Parameters" title="Empty Parameters">Empty
Parameters</a>), or they can list the variables to bind using the "keyword"
<code class="computeroutput"><span class="identifier">bind</span></code> in place of the parameter
type, using <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">bind</span></code>
@@ -892,7 +891,7 @@
<tr><td align="left" valign="top"><p>
A <code class="computeroutput"><span class="keyword">return</span><span class="special">;</span></code>
instruction from within a local block jumps to the end of the local block
- body and it does not return the enclosing function. <sup>[<a name="id875477" href="#ftn.id875477" class="footnote">10</a>]</sup>
+ body and it does not return the enclosing function. <sup>[<a name="id875690" href="#ftn.id875690" class="footnote">12</a>]</sup>
</p></td></tr>
</table></div>
<p>
@@ -928,13 +927,14 @@
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> <span class="special">{</span>
<span class="keyword">double</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">1975.0</span><span class="special">;</span>
- <span class="identifier">BOOST_LOCAL_BLOCK</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">&</span> <span class="identifier">sum</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">BOOST_LOCAL_BLOCK</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">&</span> <span class="identifier">sum</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Local block.</span>
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">sum</span> <span class="special">==</span> <span class="number">1975.0</span><span class="special">);</span> <span class="comment">// OK: Complier error if `==` confused with `=`.</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Asserted summation: "</span> <span class="special"><<</span> <span class="identifier">sum</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
<span class="keyword">return</span><span class="special">;</span> <span class="comment">// Return this local block (and not the enclosing scope).</span>
<span class="identifier">assert</span><span class="special">(</span><span class="keyword">false</span><span class="special">);</span> <span class="comment">// OK: Never executed.</span>
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_BLOCK_END</span>
+ <span class="comment">// Local block executed here.</span>
<span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
<span class="special">}</span>
@@ -953,13 +953,14 @@
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> <span class="special">{</span>
<span class="keyword">double</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">1975.0</span><span class="special">;</span>
- <span class="identifier">BOOST_LOCAL_BLOCK</span><span class="special">(</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">&</span> <span class="identifier">sum</span><span class="special">)</span> <span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">BOOST_LOCAL_BLOCK</span><span class="special">(</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">&</span> <span class="identifier">sum</span><span class="special">)</span> <span class="special">)</span> <span class="special">{</span> <span class="comment">// Local block.</span>
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">sum</span> <span class="special">==</span> <span class="number">1975.0</span><span class="special">);</span> <span class="comment">// OK: Complier error if `==` confused with `=`.</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Asserted summation: "</span> <span class="special"><<</span> <span class="identifier">sum</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
<span class="keyword">return</span><span class="special">;</span> <span class="comment">// Return this local block (and not the enclosing scope).</span>
<span class="identifier">assert</span><span class="special">(</span><span class="keyword">false</span><span class="special">);</span> <span class="comment">// OK: Never executed.</span>
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_BLOCK_END</span>
+ <span class="comment">// Local block executed here.</span>
<span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
<span class="special">}</span>
@@ -1002,7 +1003,7 @@
</tr>
<tr><td align="left" valign="top"><p>
The execution of the local exit body code is guaranteed only if the program
- does not terminate because of an uncaught exception. <sup>[<a name="id876690" href="#ftn.id876690" class="footnote">11</a>]</sup>
+ does not terminate because of an uncaught exception. <sup>[<a name="id876927" href="#ftn.id876927" class="footnote">13</a>]</sup>
</p></td></tr>
</table></div>
<p>
@@ -1010,7 +1011,7 @@
are accessible from within the local exit body. Following the same syntax
used for local functions, <code class="literal"><span class="emphasis"><em>bindings</em></span></code>
can either be empty (using <code class="computeroutput"><span class="special">(</span><span class="keyword">void</span><span class="special">)</span></code>, <code class="computeroutput"><span class="keyword">void</span></code>, or an empty macro parameter depending
- on your compiler extensions, see <a class="link" href="Tutorial.html#boost_local.Tutorial.Empty_Parameters" title="Empty Parameters">Empty
+ on your compiler, see <a class="link" href="Tutorial.html#boost_local.Tutorial.Empty_Parameters" title="Empty Parameters">Empty
Parameters</a>), or they can list the variables to bind using the "keyword"
<code class="computeroutput"><span class="identifier">bind</span></code> in place of the parameter
type, using <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">bind</span></code>
@@ -1061,7 +1062,7 @@
<span class="identifier">size_t</span> <span class="identifier">size</span> <span class="special">=</span> <span class="number">2</span><span class="special">;</span>
<span class="keyword">double</span><span class="special">*</span> <span class="identifier">nums</span> <span class="special">=</span> <span class="keyword">new</span> <span class="keyword">double</span><span class="special">[</span><span class="identifier">size</span><span class="special">];</span>
- <span class="identifier">BOOST_LOCAL_EXIT</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">&</span> <span class="identifier">size</span><span class="special">,</span> <span class="identifier">bind</span> <span class="identifier">nums</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">BOOST_LOCAL_EXIT</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">&</span> <span class="identifier">size</span><span class="special">,</span> <span class="identifier">bind</span> <span class="identifier">nums</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Local exit.</span>
<span class="keyword">if</span> <span class="special">(</span><span class="identifier">size</span> <span class="special">&&</span> <span class="identifier">nums</span><span class="special">)</span> <span class="keyword">delete</span><span class="special">[]</span> <span class="identifier">nums</span><span class="special">;</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Freed array: "</span> <span class="special"><<</span> <span class="identifier">nums</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
@@ -1070,7 +1071,7 @@
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_EXIT_END</span>
<span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
-<span class="special">}</span>
+<span class="special">}</span> <span class="comment">// Local exit executed here.</span>
</pre>
<p>
</p>
@@ -1087,7 +1088,7 @@
<span class="identifier">size_t</span> <span class="identifier">size</span> <span class="special">=</span> <span class="number">2</span><span class="special">;</span>
<span class="keyword">double</span><span class="special">*</span> <span class="identifier">nums</span> <span class="special">=</span> <span class="keyword">new</span> <span class="keyword">double</span><span class="special">[</span><span class="identifier">size</span><span class="special">];</span>
- <span class="identifier">BOOST_LOCAL_EXIT</span><span class="special">(</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">&</span> <span class="identifier">size</span><span class="special">)</span> <span class="special">(</span><span class="identifier">bind</span> <span class="identifier">nums</span><span class="special">)</span> <span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">BOOST_LOCAL_EXIT</span><span class="special">(</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">&</span> <span class="identifier">size</span><span class="special">)</span> <span class="special">(</span><span class="identifier">bind</span> <span class="identifier">nums</span><span class="special">)</span> <span class="special">)</span> <span class="special">{</span> <span class="comment">// Local exit.</span>
<span class="keyword">if</span> <span class="special">(</span><span class="identifier">size</span> <span class="special">&&</span> <span class="identifier">nums</span><span class="special">)</span> <span class="keyword">delete</span><span class="special">[]</span> <span class="identifier">nums</span><span class="special">;</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Freed array: "</span> <span class="special"><<</span> <span class="identifier">nums</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
@@ -1096,7 +1097,7 @@
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_EXIT_END</span>
<span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
-<span class="special">}</span>
+<span class="special">}</span> <span class="comment">// Local exit executed here.</span>
</pre>
<p>
</p>
@@ -1107,7 +1108,7 @@
Local exits are very similar to the <span class="emphasis"><em>scope exits</em></span> provided
by Boost.ScopeExit
with the addition that they also support constant binding and binding of
- the object <code class="computeroutput"><span class="keyword">this</span></code>. <sup>[<a name="id877946" href="#ftn.id877946" class="footnote">12</a>]</sup> Local exits can be used to emulate the <a href="http://d.digitalmars.com" target="_top">D
+ the object <code class="computeroutput"><span class="keyword">this</span></code>. <sup>[<a name="id878208" href="#ftn.id878208" class="footnote">14</a>]</sup> Local exits can be used to emulate the <a href="http://d.digitalmars.com" target="_top">D
Programming Language</a> <span class="emphasis"><em>scope guards</em></span> (see the
<a class="link" href="Examples.html#boost_local.Examples.Emulating_Ds_Scope_Guards" title="Emulating D's Scope Guards">Emulating
D's Scope Guards</a> example).
@@ -1121,7 +1122,7 @@
When local functions, local blocks, and local exits are programmed within
templates, they need to be declared using the following special macros ending
with the <code class="computeroutput"><span class="identifier">TPL</span></code> postfix (see
- the Reference section): <sup>[<a name="id878228" href="#ftn.id878228" class="footnote">13</a>]</sup>
+ the Reference section): <sup>[<a name="id878504" href="#ftn.id878504" class="footnote">15</a>]</sup>
</p>
<pre class="programlisting"><code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_PARAMS_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_PARAMS_TPL">BOOST_LOCAL_FUNCTION_PARAMS_TPL</a></code><span class="special">(</span><span class="emphasis"><em>parameters</em></span><span class="special">)</span>
<code class="computeroutput"><a class="link" href="../BOOST_LOCAL_BLOCK_TPL.html" title="Macro BOOST_LOCAL_BLOCK_TPL">BOOST_LOCAL_BLOCK_TPL</a></code><span class="special">(</span><span class="emphasis"><em>bindings</em></span><span class="special">)</span>
@@ -1171,6 +1172,7 @@
<span class="keyword">int</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span>
<span class="comment">// Use `..._TPL()` macros within templates.</span>
+
<span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS_TPL</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">num</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">factor</span><span class="special">,</span>
<span class="identifier">bind</span><span class="special">&</span> <span class="identifier">sum</span><span class="special">)</span> <span class="special">{</span>
<span class="identifier">sum</span> <span class="special">+=</span> <span class="identifier">factor</span> <span class="special">*</span> <span class="identifier">num</span><span class="special">;</span>
@@ -1218,6 +1220,7 @@
<span class="keyword">int</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span>
<span class="comment">// Use `..._TPL()` macros within templates.</span>
+
<span class="identifier">T</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS_TPL</span><span class="special">(</span> <span class="special">(</span><span class="identifier">T</span> <span class="identifier">num</span><span class="special">)</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">factor</span><span class="special">)</span>
<span class="special">(</span><span class="identifier">bind</span><span class="special">&</span> <span class="identifier">sum</span><span class="special">)</span> <span class="special">)</span> <span class="special">{</span>
<span class="keyword">return</span> <span class="identifier">sum</span> <span class="special">+=</span> <span class="identifier">factor</span> <span class="special">*</span> <span class="identifier">num</span><span class="special">;</span>
@@ -1254,52 +1257,55 @@
</div>
<div class="footnotes">
<br><hr width="100" align="left">
-<div class="footnote"><p><sup>[<a id="ftn.id866792" href="#id866792" class="para">2</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id866866" href="#id866866" class="para">3</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> If the local function body
were instead passed as a macro parameter, it would be expanded on a single
line of code (because macros always expand as a single line of code). Therefore,
eventual compiler error line numbers would all report the same value and
would no longer be useful to pinpoint the error.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id866828" href="#id866828" class="para">3</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id866902" href="#id866902" class="para">4</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> The local function name must
be passed to the macro <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code>
ending the function definition so this macro can declare a local variable
- with the local function name to hold the local functor object.
+ with the local function name to hold the local function object.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id868853" href="#id868853" class="para">4</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id868966" href="#id868966" class="para">5</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> The assignment symbol <code class="computeroutput"><span class="special">=</span></code> cannot be used to specify default parameter
values because default values are not part of the parameter type so they
cannot be handled using template metaprogamming. Default parameter values
need to be separated from the rest of the parameter declaration using the
preprocessor. Specifically, this library needs to use preprocessor mataprogramming
to remove default values when constructing the local function type and
- it counts the number of default values to provide the correct set of call
- operators for the local functor object.
+ then to count the number of default values to provide the correct set of
+ call operators for the local functor. Therefore, the symbol <code class="computeroutput"><span class="special">=</span></code> cannot be used because it cannot be handled
+ by preprocessor metaprogramming (specifically, such a non-alphanumeric
+ symbol cannot be detected by preprocessor metaprogramming because it cannot
+ be concatenated by the preprocessor).
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id870214" href="#id870214" class="para">5</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id870490" href="#id870490" class="para">6</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> By binding a variable in scope,
the local function declaration is specifying that such a variable should
be accessible within the local function body regardless of its type. Semantically,
this binding should be seen as an "extension" of the scope of
the bound variable from the enclosing scope to the scope of the local function
- body. Contrary to the semantics of a function parameter passing, in-scope
- variable binding does not depend on the variable type but just on the variable
- name: "The variable in scope named <span class="emphasis"><em>x</em></span> should be
- accessible within the local function named <span class="emphasis"><em>l</em></span>".
- This is especially useful for maintenance so if a bound variable type is
- changed, the local function declaration does not have to change.
+ body. Therefore, contrary to the semantic of passing a function parameter,
+ the semantic of binding a variable not depend on the variable type but
+ just on the variable name: "The variable in scope named <span class="emphasis"><em>x</em></span>
+ should be accessible within the local function named <span class="emphasis"><em>l</em></span>".
+ For example, this is useful for maintenance because if a bound variable
+ type is changed, the local function declaration does not have to change.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id870296" href="#id870296" class="para">6</a>] </sup>
- The token <code class="computeroutput"><span class="identifier">bind</span></code> is not a
- real keyword of the C++ language. This library parses <code class="computeroutput"><span class="identifier">bind</span></code>
- during macro expansion using preprocessor metaprogramming. Therefore,
- <code class="computeroutput"><span class="identifier">bind</span></code> can be considered
- a new "keyword" only at the preprocessor metaprogramming level
- within the syntax defined by the macros of this library -- thus it is referred
- to as a "keyword" only within quotes.
+<div class="footnote"><p><sup>[<a id="ftn.id870572" href="#id870572" class="para">7</a>] </sup>
+ Obviously, the token <code class="computeroutput"><span class="identifier">bind</span></code>
+ is not a keyword of the C++ language. This library parses the token <code class="computeroutput"><span class="identifier">bind</span></code> during macro expansion using preprocessor
+ metaprogramming (see the <a class="link" href="Implementation.html" title="Appendix: Implementation">Implementation</a>
+ section). Therefore, <code class="computeroutput"><span class="identifier">bind</span></code>
+ can be considered a new "keyword" only at the preprocessor metaprogramming
+ level within the syntax defined by the macros of this library -- thus it
+ is referred to as a "keyword" only within quotes.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id870866" href="#id870866" class="para">7</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id870878" href="#id870878" class="para">8</a>] </sup>
An historical note: Constant binding of variables in scope was the main
use case that originally motivated the authors in developing this library.
The authors needed to locally create a chuck of code to assert some correctness
@@ -1314,26 +1320,27 @@
generates an error because the bound variable is of <code class="computeroutput"><span class="keyword">const</span></code>
type within the local function body.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id872045" href="#id872045" class="para">8</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id871947" href="#id871947" class="para">9</a>] </sup>
+ <span class="bold"><strong>Rationale.</strong></span> The special name <code class="computeroutput"><span class="identifier">this_</span></code> was chosen following <a href="http://boost.2283326.n4.nabble.com/local-this-or-this-td3423912.html" target="_top">Boost
+ practises</a> which postfix with an underscore identifiers that are
+ named after keywords (the C++ keyword <code class="computeroutput"><span class="keyword">this</span></code>
+ in this case).
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.id872256" href="#id872256" class="para">10</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> This limitation comes from
the fact that <code class="computeroutput"><span class="keyword">this</span></code> is a
reserved C++ keyword so it cannot be used as the name of the internal
- parameter passing the bound object to the local function body. It would
- be possible to use <code class="computeroutput"><span class="keyword">this</span></code>
+ parameter that passes the bound object to the local function body. It
+ would have been possible to use <code class="computeroutput"><span class="keyword">this</span></code>
(instead of <code class="computeroutput"><span class="identifier">this_</span></code>) within
the local function body either at the expenses of copying the bound object
(which would introduce run-time overhead and also the stringent requirement
that the bound object must have a deep copy constructor) or by relying
on an <a href="http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/d3a86f27277f713b" target="_top">undefined
behaviour of <code class="computeroutput"><span class="keyword">static_cast</span></code></a>
- (which might not work on all platforms at the cost of portability). Finally,
- the special name <code class="computeroutput"><span class="identifier">this_</span></code>
- was chosen following <a href="http://boost.2283326.n4.nabble.com/local-this-or-this-td3423912.html" target="_top">Boost
- practise</a> to postfix with an underscore identifiers that are named
- after keywords (the C++ keyword <code class="computeroutput"><span class="keyword">this</span></code>
- in this case).
+ (which might not work on all platforms at the cost of portability).
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id872170" href="#id872170" class="para">9</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id872349" href="#id872349" class="para">11</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> The local function body cannot
be a static member function of the local functor object in order to support
recursion (because the local function name is specified by the <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code>
@@ -1341,12 +1348,12 @@
member variable named after the local function and local classes cannot
have static member variables in C++) and nesting (because the argument
binding variable must be declared as a member variable so it is visible
- in a local function nested within the body member function). Therefore,
- from within the local function body the variable <code class="computeroutput"><span class="keyword">this</span></code>
- is visible but it refers to the local functor object and not to the bound
- object.
+ in a local function nested within the body member function) -- see the
+ <a class="link" href="Implementation.html" title="Appendix: Implementation">Implementation</a> section.
+ Therefore, from within the local function body the variable <code class="computeroutput"><span class="keyword">this</span></code> is visible but it refers to the local
+ functor and not to the bound object.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id875477" href="#id875477" class="para">10</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id875690" href="#id875690" class="para">12</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> Programmers might expect
<code class="computeroutput"><span class="keyword">return</span><span class="special">;</span></code>
to exit the enclosing function instead of the local block (or local exit),
@@ -1364,7 +1371,7 @@
<code class="computeroutput"><span class="identifier">BOOST_LOCAL_RETURN</span><span class="special">;</span></code>)
to exit local blocks (and local exits).
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id876690" href="#id876690" class="para">11</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id876927" href="#id876927" class="para">13</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> This library (as well as
<a href="http://www.boost.org/doc/libs/release/libs/scope_exit/doc/html/index.html" target="_top">Boost.ScopeExit</a>)
uses the destructor of a local variable to automatically execute the
@@ -1375,7 +1382,7 @@
scope exit code even if the main program terminates because of an uncaught
exception.)
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id877946" href="#id877946" class="para">12</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id878208" href="#id878208" class="para">14</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> This library could be merged
together with Boost.ScopeExit
into a new library named Boost.Scope (from the meaning of the word "scope"
@@ -1391,18 +1398,20 @@
macro will not be backward compatible with the current Boost.ScopeExit
macro because it will require to prefix the bound variable with <code class="computeroutput"><span class="identifier">bind</span></code> or <code class="computeroutput"><span class="keyword">const</span>
<span class="identifier">bind</span></code> (in order to differentiate
- from constant and non-constant binding). Local blocks would be named "scope
- blocks" and they would be provided by the <code class="computeroutput"><span class="identifier">BOOST_SCOPE_BLOCK</span><span class="special">...</span></code> macros (the "scope block"
+ from constant and non-constant binding and to prevent the bound tokens
+ from ever starting with a non-alphanumeric symbol like <code class="computeroutput"><span class="special">&</span></code>).
+ Local blocks would be named "scope blocks" and they would be
+ provided by the <code class="computeroutput"><span class="identifier">BOOST_SCOPE_BLOCK</span><span class="special">...</span></code> macros (the "scope block"
name seems reasonably expressive). However, local functions would have
to be named "scope functions" and they would be provided by the
<code class="computeroutput"><span class="identifier">BOOST_SCOPE_FUNCTION</span><span class="special">...</span></code>
- macros. This name might not expressive enough because local functions are
- not known under the name of "scope functions" -- they are indeed
- known by either the name of "local functions" or by the name
- of "<a href="http://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html" target="_top">nested
+ macros. This name might not be expressive enough because local functions
+ are not known under the name of "scope functions" -- they are
+ indeed known by either the name of "local functions" or by the
+ name of "<a href="http://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html" target="_top">nested
functions</a>" (GCC compiler extension).
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id878228" href="#id878228" class="para">13</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id878504" href="#id878504" class="para">15</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> Within templates, this library
needs to use <code class="computeroutput"><span class="keyword">typename</span></code> to explicitly
indicate that some expressions evaluate to a type. Because C++ does not
Modified: sandbox/local/libs/local/doc/html/index.html
==============================================================================
--- sandbox/local/libs/local/doc/html/index.html (original)
+++ sandbox/local/libs/local/doc/html/index.html 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -27,7 +27,7 @@
</h3></div></div></div>
<div><p class="copyright">Copyright © 2009-2011 Lorenzo Caminiti</p></div>
<div><div class="legalnotice">
-<a name="id808764"></a><p>
+<a name="id808762"></a><p>
Use, modification, and distribution is subject to the Boost Software License,
Version 1.0 (see accompanying file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
</p>
@@ -78,13 +78,15 @@
defined within a member function can bind the enclosing object <code class="computeroutput"><span class="keyword">this</span></code>.
</li>
<li class="listitem">
- The local function body is programmed using the usual C++ syntax (as a
- consequence, compiler error messages and related line numbers retain their
- usual meaning).
+ The local function body is programmed using the usual C++ statement syntax
+ (as a consequence, compiler error messages retain their usual meaning and
+ format).
</li>
<li class="listitem">
- Local functions can be passed as template parameters (so they can be conveniently
- passed to STL algorithms, etc).
+ Local functions can be passed as template parameters (e.g., they can be
+ conveniently passed to STL algorithms, this is in contrast to functors
+ implemented using local classes see [2657]
+ and the <a class="link" href="boost_local/Alternatives.html" title="Appendix: Alternatives">Alternatives</a> section).
</li>
<li class="listitem">
However, local functions must be defined within a declarative context (e.g.,
@@ -98,14 +100,14 @@
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
<span class="emphasis"><em>Local blocks</em></span> which define blocks of code that bind
- variables from the enclosing scope. Local blocks allow programmers to bind
- variables as constants (<span class="emphasis"><em>constant binding</em></span>) so to prevent
- local chunks of code from modifying selected variables.
+ variables from the enclosing scope (including the object <code class="computeroutput"><span class="keyword">this</span></code>). Local blocks allow programmers to
+ bind variables as constants (<span class="emphasis"><em>constant binding</em></span>) to
+ prevent local chunks of code from modifying selected variables.
</li>
<li class="listitem">
<span class="emphasis"><em>Local exits</em></span> which define blocks of code that are executed
- when the enclosing scope is exited (again with support for constant binding
- and binding of the object <code class="computeroutput"><span class="keyword">this</span></code>).
+ when the enclosing scope is exited (again with support for binding variables
+ in scope including the object <code class="computeroutput"><span class="keyword">this</span></code>).
</li>
</ul></div>
<a name="boost_local.Introduction.two_syntaxes"></a><h6>
@@ -126,10 +128,11 @@
<li class="listitem">
The <span class="emphasis"><em>variadic macro synstax</em></span> is available only on C++
compilers that support <a href="http://en.wikipedia.org/wiki/Variadic_macro" target="_top">variadic
- macros</a> (variadic macros are now supported by essentially all modern
- C++ compilers including GCC and MSVC). This syntax allows to use commas
- <code class="computeroutput"><span class="special">,</span></code> to separate macro parameters
- therefore resembling the usual C++ syntax for function parameter declaration.
+ macros</a> (variadic macros were first introduced by the C99 standard
+ and they are now supported by essentially all modern C++ compilers including
+ GCC and MSVC). This syntax allows to use commas <code class="computeroutput"><span class="special">,</span></code>
+ to separate macro parameters therefore resembling the usual C++ syntax
+ for function parameter declaration.
</li>
</ul></div>
<p>
@@ -137,9 +140,9 @@
macros and only the sequencing macro syntax on compilers that do not support
variadic macros. The use of the variadic macro syntax might lead to more readable
code however it should only be used when programmers know that their code will
- be compiled with variadic macros support to avoid portability issues. Most
- of the examples presented in this documentation provide a side-by-side comparison
- of both syntaxes.
+ always be compiled with variadic macros support to avoid portability issues.
+ Most of the examples presented in this documentation provide a side-by-side
+ comparison of the two syntaxes.
</p>
<a name="boost_local.Introduction.an_example"></a><h6>
<a name="boost_local.Introduction.an_example-heading"></a>
@@ -152,8 +155,8 @@
local exit is used to automatically release the array's memory when the enclosing
function exits. A local block is used to assert the correct final value of
the summation in a constant-correct context (therefore preventing the assertion
- from mistakenly changing any of the variables in scope). See the <a class="link" href="boost_local/Tutorial.html" title="Tutorial">Tutorial</a>
- section for more details.
+ instruction from mistakenly changing any of the variables in scope). See the
+ <a class="link" href="boost_local/Tutorial.html" title="Tutorial">Tutorial</a> section for more details.
</p>
<div class="informaltable"><table class="table">
<colgroup>
@@ -330,33 +333,33 @@
see the <a class="link" href="boost_local/Tutorial.html" title="Tutorial">Tutorial</a> section).
On C99 and later preprocessors which support variadic macros, the same
parameter macro also allows to specify the parameters separated by commas
- instead that wrapped within parenthesis <code class="literal"><span class="emphasis"><em>parameter-type
- parameter-name</em></span>,<span class="emphasis"><em>...</em></span></code> so to support
+ instead than wrapped within parenthesis <code class="literal"><span class="emphasis"><em>parameter-type
+ parameter-name</em></span>,<span class="emphasis"><em>...</em></span></code> thus supporting
a syntax similar to the usual C++ syntax for function parameter lists.
The local function result type is specified just before the parameter macro.
</li>
<li class="listitem">
- This library macros introduce the special "keyword" <code class="computeroutput"><span class="identifier">bind</span></code> which can be used instead of the
+ The library macros introduce the special "keyword" <code class="computeroutput"><span class="identifier">bind</span></code> which can be used instead of the
parameter type to bind variables in scope. Variables can be bound by value,
by reference, by constant value, and by constant reference. In addition,
the object <code class="computeroutput"><span class="keyword">this</span></code> can be bound
- (eventually by constant value but never by reference or constant reference)
- from within a non-static member function (see the <a class="link" href="boost_local/Tutorial.html" title="Tutorial">Tutorial</a>
+ (eventually by constant value but never by reference or constant reference
+ <sup>[<a name="id865420" href="#ftn.id865420" class="footnote">1</a>]</sup> ) from within a non-static member function (see the <a class="link" href="boost_local/Tutorial.html" title="Tutorial">Tutorial</a>
section). For example, the variable <code class="computeroutput"><span class="identifier">factor</span></code>
is bound by constant value so it cannot be mistakenly modified by the local
function body. The variable <code class="computeroutput"><span class="identifier">sum</span></code>
is instead bound by non-constant reference because the local function needs
- to change its value to report the summation result to the enclosing scope.
+ to change its value to report the summation value to the enclosing scope.
</li>
<li class="listitem">
The local function body is programmed outside the macros with the usual
C++ syntax. Eventual compiler error messages and related line numbers retain
- their usual meaning. Exceptions specifications can be programmed outside
- the macro and just before the body code block <code class="computeroutput"><span class="special">{...}</span></code>
- as usual. Finally, within the local function body the type of a bound variable
- can be accessed using <code class="literal"><code class="computeroutput"><a class="link" href="BOOST_LOCAL_TYPEOF.html" title="Macro BOOST_LOCAL_TYPEOF">BOOST_LOCAL_TYPEOF</a></code>(<span class="emphasis"><em>bound-variable-name</em></span>)</code>
- (see the <a class="link" href="boost_local/Advanced_Topics.html" title="Advanced Topics">Advanced Topics</a>
- section).
+ their usual meaning and format. Exceptions specifications can be programmed
+ outside the macro and just before the body code block <code class="computeroutput"><span class="special">{...}</span></code>.
+ Finally, within the local function body the type of a bound variable can
+ be accessed using <code class="literal"><code class="computeroutput"><a class="link" href="BOOST_LOCAL_TYPEOF.html" title="Macro BOOST_LOCAL_TYPEOF">BOOST_LOCAL_TYPEOF</a></code>(<span class="emphasis"><em>bound-variable-name</em></span>)</code>.
+ (See the <a class="link" href="boost_local/Advanced_Topics.html" title="Advanced Topics">Advanced Topics</a>
+ section.)
</li>
<li class="listitem">
The macro ending the local function definition specifies the local function
@@ -364,19 +367,20 @@
after the ending macro.
</li>
<li class="listitem">
- The local function macros declare a functor object local to the enclosing
- scope named <code class="computeroutput"><span class="identifier">add</span></code>. The functor
- <code class="computeroutput"><span class="identifier">add</span></code> has <code class="computeroutput"><span class="keyword">void</span></code>
- result type, it can be called by specifying one parameter of type <code class="computeroutput"><span class="keyword">double</span></code>, and it has access to the variables
- in scope <code class="computeroutput"><span class="identifier">factor</span></code> (by constant
- value) and <code class="computeroutput"><span class="identifier">sum</span></code> (by reference).
+ The local function macros declare a function object (a.k.a., functor) local
+ to the enclosing scope named <code class="computeroutput"><span class="identifier">add</span></code>.
+ The functor <code class="computeroutput"><span class="identifier">add</span></code> has <code class="computeroutput"><span class="keyword">void</span></code> result type, it can be called by specifying
+ one parameter <code class="computeroutput"><span class="identifier">num</span></code> of type
+ <code class="computeroutput"><span class="keyword">double</span></code>, and it has access
+ to the variables in scope <code class="computeroutput"><span class="identifier">factor</span></code>
+ (by constant value) and <code class="computeroutput"><span class="identifier">sum</span></code>
+ (by reference).
</li>
<li class="listitem">
The <span class="bold"><strong>local exit</strong></span> declaration macro only
specifies the variables in scope to bind (by reference or value and eventually
as constants). Exceptions specifications can be programmed outside the
- macro and just before the body code block <code class="computeroutput"><span class="special">{...}</span></code>
- as usual.
+ macro and just before the body code block <code class="computeroutput"><span class="special">{...}</span></code>.
</li>
<li class="listitem">
The local exit code will be automatically executed when the enclosing scope
@@ -389,14 +393,14 @@
</li>
<li class="listitem">
The local function <code class="computeroutput"><span class="identifier">add</span></code>
- can also be passed as a template parameter (for example, to the STL <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span></code> algorithm).
+ can be passed as a template parameter (e.g., to the STL <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span></code>
+ algorithm).
</li>
<li class="listitem">
The <span class="bold"><strong>local block</strong></span> declaration macro only
specifies the variables in scope to bind (by reference or value and eventually
as constants). Exceptions specifications can be programmed outside the
- macro and just before the body code block <code class="computeroutput"><span class="special">{...}</span></code>
- as usual.
+ macro and just before the body code block <code class="computeroutput"><span class="special">{...}</span></code>.
</li>
<li class="listitem">
The local block code is executed "in place" where it is programmed
@@ -414,9 +418,15 @@
</li>
</ol></div>
</div>
+<div class="footnotes">
+<br><hr width="100" align="left">
+<div class="footnote"><p><sup>[<a id="ftn.id865420" href="#id865420" class="para">1</a>] </sup>
+ C++ does not allow to obtain a reference to the pointer <code class="computeroutput"><span class="keyword">this</span></code>.
+ </p></div>
+</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: May 03, 2011 at 23:52:20 GMT</small></p></td>
+<td align="left"><p><small>Last revised: May 05, 2011 at 03:09:14 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
Modified: sandbox/local/libs/local/doc/qbk/getting_started.qbk
==============================================================================
--- sandbox/local/libs/local/doc/qbk/getting_started.qbk (original)
+++ sandbox/local/libs/local/doc/qbk/getting_started.qbk 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -12,21 +12,22 @@
Programmers should have enough knowledge to use this library after reading the __Introduction__, __Getting_Started__, and __Tutorial__ sections.
The __Advanced_Topics__ and __Reference__ sections can be consulted at a later point to gain a more advanced knowledge of the library.
-All the other sections of this documentation are for reference only.
+All the other sections of this documentation are optional.
-Some footnotes are marked by the word "*Rationale*" because they explain reasons behind decisions made during the design and implementation of this library.
+Some footnotes are marked by the word "*Rationale*".
+They explain reasons behind decisions made during the design and implementation of this library.
[endsect]
[section Compilers and Platforms]
-The implementation of this library uses preprocessor and template metaprogramming (as supported by __Boost_Preprocessor__ and __Boost_MPL__), templates with partial specializations and function pointers (to support an interface similar to the one of __Boost_Function__).
+The implementation of this library uses preprocessor and template metaprogramming (as supported by __Boost_Preprocessor__ and __Boost_MPL__), templates with partial specializations and function pointers (similarly to __Boost_Function__).
As a consequence, this library is fairly demanding on compilers' compliance with the ISO C++ standard.
At present, this library has been successfully compiled and tested on the following compilers and platforms:
-# GCC 4.2.4 on Ubuntu Linux.
-# GCC 3.4.4 on Cygwin.
-# Miscrosoft Visual Studio 8.0 on Windows XP.
+# GNU Compiler Collection (GCC) 4.5.1 (with and without C++0x features enabled) on Ubuntu Linux 10.
+# GCC 4.3.4 on Cygwin.
+# Miscrosoft Visual Studio Compiler (MSVC) 8.0 on Windows XP.
This library has not yet been tested on any other compiler or platform.
@@ -47,14 +48,14 @@
``[headerref boost/local/block.hpp] /local blocks/``
``[headerref boost/local/exit.hpp] /local exits/``
``[headerref boost/local/typeof.hpp] /bound variable type deduction/``
- ``[headerref boost/local/config.hpp] /configuration macros/``
+ ``[headerref boost/local/config.hpp] /library configuration macros/``
-The following symbols are part of the library private API, they are not documented, and they should not be directly used by programmers:
+The followings are part of the library private API, they are not documented, and they should not be directly used by programmers:
[footnote
*Rationale.*
This library concatenates symbols specified by the programmers (e.g., the local function name) with other symbols (e.g., special prefixes or preprocessor line numbers) to make internal symbols with unique names to avoid name clashes.
-These symbols are separated by the letter "`X`" when they are concatenated so they can be read more easily while debugging the library.
-The underscore character "`_`" could not be used instead of the letter "`X`" because if the original symbols already contained a leading or trailing underscore, the concatenation would result in a symbol with double underscores "`__`" which is reserved by the C++ standard.
+These symbols are separated by the letter "`X`" when they are concatenated so they read more easily during debugging.
+The underscore character "`_`" could not be used instead of the letter "`X`" because if the original symbols already contained a leading or trailing underscore, the concatenation could result in a symbol with double underscores "`__`" which is reserved by the C++ standard.
]
* Any symbol defined by files within the `"boost/local/aux_/"` directory (these header files should not be directly included by programmers).
@@ -69,7 +70,7 @@
Some of the library behaviour can be changed at compile-time by defining special /configuration macros/.
If a configuration macro is left undefined, the library will use an appropriate default value for it.
-All configuration macros have names prefixed by `BOOST_LOCAL_CONFIG_...` (see __Reference__ section).
+All configuration macros have names prefixed by `BOOST_LOCAL_CONFIG_...` (see the __Reference__ section).
It is strongly recommended not to change the library configuration macro definitions unless strictly necessary.
[endsect]
Modified: sandbox/local/libs/local/doc/qbk/introduction.qbk
==============================================================================
--- sandbox/local/libs/local/doc/qbk/introduction.qbk (original)
+++ sandbox/local/libs/local/doc/qbk/introduction.qbk 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -13,15 +13,15 @@
* Local functions can access, or better [@http://en.wikipedia.org/wiki/Name_binding /bind/], any of the variables from the enclosing scope.
Furthermore, local functions defined within a member function can bind the enclosing object `this`.
-* The local function body is programmed using the usual C++ syntax (as a consequence, compiler error messages and related line numbers retain their usual meaning).
-* Local functions can be passed as template parameters (so they can be conveniently passed to STL algorithms, etc).
+* The local function body is programmed using the usual C++ statement syntax (as a consequence, compiler error messages retain their usual meaning and format).
+* Local functions can be passed as template parameters (e.g., they can be conveniently passed to STL algorithms, this is in contrast to functors implemented using local classes see __N2657__ and the __Alternatives__ section).
* However, local functions must be defined within a declarative context (e.g., at a point in the code where local variables can be declared) thus they cannot be defined within an expression.
In addition to local functions, this library also supports the following features:
-* /Local blocks/ which define blocks of code that bind variables from the enclosing scope.
-Local blocks allow programmers to bind variables as constants (/constant binding/) so to prevent local chunks of code from modifying selected variables.
-* /Local exits/ which define blocks of code that are executed when the enclosing scope is exited (again with support for constant binding and binding of the object `this`).
+* /Local blocks/ which define blocks of code that bind variables from the enclosing scope (including the object `this`).
+Local blocks allow programmers to bind variables as constants (/constant binding/) to prevent local chunks of code from modifying selected variables.
+* /Local exits/ which define blocks of code that are executed when the enclosing scope is exited (again with support for binding variables in scope including the object `this`).
[h5 Two Syntaxes]
@@ -30,18 +30,18 @@
* The /sequencing macro syntax/ is fully compliant with the ISO C++ standard and supported on all C++ compilers.
This syntax requires to wrap the local function parameters and bound variables between round parenthesis `()`.
-* The /variadic macro synstax/ is available only on C++ compilers that support [@http://en.wikipedia.org/wiki/Variadic_macro variadic macros] (variadic macros are now supported by essentially all modern C++ compilers including GCC and MSVC).
+* The /variadic macro synstax/ is available only on C++ compilers that support [@http://en.wikipedia.org/wiki/Variadic_macro variadic macros] (variadic macros were first introduced by the C99 standard and they are now supported by essentially all modern C++ compilers including GCC and MSVC).
This syntax allows to use commas `,` to separate macro parameters therefore resembling the usual C++ syntax for function parameter declaration.
The same library macros accept both syntaxes on compilers that support variadic macros and only the sequencing macro syntax on compilers that do not support variadic macros.
-The use of the variadic macro syntax might lead to more readable code however it should only be used when programmers know that their code will be compiled with variadic macros support to avoid portability issues.
-Most of the examples presented in this documentation provide a side-by-side comparison of both syntaxes.
+The use of the variadic macro syntax might lead to more readable code however it should only be used when programmers know that their code will always be compiled with variadic macros support to avoid portability issues.
+Most of the examples presented in this documentation provide a side-by-side comparison of the two syntaxes.
[h5 An Example]
In the following example, a local function is passed to the STL `std::for_each` algorithm to add together the values of an array (variables in scope are bound to the local function by both constant value and non-constant reference).
A local exit is used to automatically release the array's memory when the enclosing function exits.
-A local block is used to assert the correct final value of the summation in a constant-correct context (therefore preventing the assertion from mistakenly changing any of the variables in scope).
+A local block is used to assert the correct final value of the summation in a constant-correct context (therefore preventing the assertion instruction from mistakenly changing any of the variables in scope).
See the __Tutorial__ section for more details.
[table
@@ -53,29 +53,33 @@
# Include the header files for this library local functions, local blocks, and local exits.
# The *local function* parameter macro takes a __Boost_Preprocessor__ sequence of tokens listing each parameter type and name wrapped within round parenthesis [^(['parameter-type parameter-name])['...]] (default parameter values can also be specified using a special syntax, see the __Tutorial__ section).
-On C99 and later preprocessors which support variadic macros, the same parameter macro also allows to specify the parameters separated by commas instead that wrapped within parenthesis [^['parameter-type parameter-name],['...]] so to support a syntax similar to the usual C++ syntax for function parameter lists.
+On C99 and later preprocessors which support variadic macros, the same parameter macro also allows to specify the parameters separated by commas instead than wrapped within parenthesis [^['parameter-type parameter-name],['...]] thus supporting a syntax similar to the usual C++ syntax for function parameter lists.
The local function result type is specified just before the parameter macro.
-# This library macros introduce the special "keyword" `bind` which can be used instead of the parameter type to bind variables in scope.
+# The library macros introduce the special "keyword" `bind` which can be used instead of the parameter type to bind variables in scope.
Variables can be bound by value, by reference, by constant value, and by constant reference.
-In addition, the object `this` can be bound (eventually by constant value but never by reference or constant reference) from within a non-static member function (see the __Tutorial__ section).
+In addition, the object `this` can be bound (eventually by constant value but never by reference or constant reference
+[footnote
+C++ does not allow to obtain a reference to the pointer `this`.
+]
+) from within a non-static member function (see the __Tutorial__ section).
For example, the variable `factor` is bound by constant value so it cannot be mistakenly modified by the local function body.
-The variable `sum` is instead bound by non-constant reference because the local function needs to change its value to report the summation result to the enclosing scope.
+The variable `sum` is instead bound by non-constant reference because the local function needs to change its value to report the summation value to the enclosing scope.
# The local function body is programmed outside the macros with the usual C++ syntax.
-Eventual compiler error messages and related line numbers retain their usual meaning.
-Exceptions specifications can be programmed outside the macro and just before the body code block `{...}` as usual.
-Finally, within the local function body the type of a bound variable can be accessed using [^__BOOST_LOCAL_TYPEOF__(['bound-variable-name])] (see the __Advanced_Topics__ section).
+Eventual compiler error messages and related line numbers retain their usual meaning and format.
+Exceptions specifications can be programmed outside the macro and just before the body code block `{...}`.
+Finally, within the local function body the type of a bound variable can be accessed using [^__BOOST_LOCAL_TYPEOF__(['bound-variable-name])]. (See the __Advanced_Topics__ section.)
# The macro ending the local function definition specifies the local function name.
No semicolon `;` is required after the ending macro.
-# The local function macros declare a functor object local to the enclosing scope named `add`.
-The functor `add` has `void` result type, it can be called by specifying one parameter of type `double`, and it has access to the variables in scope `factor` (by constant value) and `sum` (by reference).
+# The local function macros declare a function object (a.k.a., functor) local to the enclosing scope named `add`.
+The functor `add` has `void` result type, it can be called by specifying one parameter `num` of type `double`, and it has access to the variables in scope `factor` (by constant value) and `sum` (by reference).
# The *local exit* declaration macro only specifies the variables in scope to bind (by reference or value and eventually as constants).
-Exceptions specifications can be programmed outside the macro and just before the body code block `{...}` as usual.
+Exceptions specifications can be programmed outside the macro and just before the body code block `{...}`.
# The local exit code will be automatically executed when the enclosing scope is exited.
# Local exits are anonymous so their ending macro takes no argument.
No semicolon `;` is required after the ending macro.
-# The local function `add` can also be passed as a template parameter (for example, to the STL `std::for_each` algorithm).
+# The local function `add` can be passed as a template parameter (e.g., to the STL `std::for_each` algorithm).
# The *local block* declaration macro only specifies the variables in scope to bind (by reference or value and eventually as constants).
-Exceptions specifications can be programmed outside the macro and just before the body code block `{...}` as usual.
+Exceptions specifications can be programmed outside the macro and just before the body code block `{...}`.
# The local block code is executed "in place" where it is programmed like a usual C++ block of code.
In this example, the compiler will correctly generate an error if the assignment operator `=` is mistakenly used instead of the equality operator `==` because the variable `sum` is bound by constant reference so it cannot be modified within the local block.
# Local blocks are anonymous so their ending macro takes no argument.
Modified: sandbox/local/libs/local/doc/qbk/tutorial.qbk
==============================================================================
--- sandbox/local/libs/local/doc/qbk/tutorial.qbk (original)
+++ sandbox/local/libs/local/doc/qbk/tutorial.qbk 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -38,7 +38,7 @@
]
The local function body is specified in a code block `{ ... }` using the usual C++ syntax.
-The body is specified outside any of the macros so eventual compiler error messages and related line numbers retain their usual meaning.
+The body is specified outside any of the macros so eventual compiler error messages and related line numbers retain their usual meaning and format.
[footnote
*Rationale.*
If the local function body were instead passed as a macro parameter, it would be expanded on a single line of code (because macros always expand as a single line of code).
@@ -48,7 +48,7 @@
The macro `__BOOST_LOCAL_FUNCTION_NAME__` is used to end the local function definition and to specify the local function name.
[footnote
*Rationale.*
-The local function name must be passed to the macro `__BOOST_LOCAL_FUNCTION_NAME__` ending the function definition so this macro can declare a local variable with the local function name to hold the local functor object.
+The local function name must be passed to the macro `__BOOST_LOCAL_FUNCTION_NAME__` ending the function definition so this macro can declare a local variable with the local function name to hold the local function object.
]
For example, let's program a local function named `add` that adds together two integer numbers `x` and `y` -- for simplicity, we will not bind any of the variables in scope just yet (binding is explained later in this section):
@@ -109,7 +109,8 @@
[footnote
[*Rationale.] The assignment symbol `=` cannot be used to specify default parameter values because default values are not part of the parameter type so they cannot be handled using template metaprogamming.
Default parameter values need to be separated from the rest of the parameter declaration using the preprocessor.
-Specifically, this library needs to use preprocessor mataprogramming to remove default values when constructing the local function type and it counts the number of default values to provide the correct set of call operators for the local functor object.
+Specifically, this library needs to use preprocessor mataprogramming to remove default values when constructing the local function type and then to count the number of default values to provide the correct set of call operators for the local functor.
+Therefore, the symbol `=` cannot be used because it cannot be handled by preprocessor metaprogramming (specifically, such a non-alphanumeric symbol cannot be detected by preprocessor metaprogramming because it cannot be concatenated by the preprocessor).
]
The keyword `default` is used instead:
@@ -122,14 +123,14 @@
] ]
]
-For example, let's assume that the we want to program a local function `add(x, y)` similar to the one programmed before but where the second parameter `y` is optional and has a default value of `2`:
+For example, let's program a local function `add(x, y)` similar to the one programmed before but where the second parameter `y` is optional and has a default value of `2`:
[table
[ [__Variadic_Macro_Syntax__] [__Sequencing_Macro_Syntax__] ]
[ [ [add_x_y_default_va_cpp] ] [ [add_x_y_default_cpp] ] ]
]
-If this variadic macro syntax seems strange, programmers could define a `WITH_DEFAULT` macro similar to the following if they think it improves readability:
+If this variadic macro syntax seems strange, programmers can define a `WITH_DEFAULT` macro similar to the following (if they think that improves readability):
[table
[ [__Variadic_Macro_Syntax__] ]
@@ -146,8 +147,8 @@
*Rationale.*
By binding a variable in scope, the local function declaration is specifying that such a variable should be accessible within the local function body regardless of its type.
Semantically, this binding should be seen as an "extension" of the scope of the bound variable from the enclosing scope to the scope of the local function body.
-Contrary to the semantics of a function parameter passing, in-scope variable binding does not depend on the variable type but just on the variable name: "The variable in scope named /x/ should be accessible within the local function named /l/".
-This is especially useful for maintenance so if a bound variable type is changed, the local function declaration does not have to change.
+Therefore, contrary to the semantic of passing a function parameter, the semantic of binding a variable not depend on the variable type but just on the variable name: "The variable in scope named /x/ should be accessible within the local function named /l/".
+For example, this is useful for maintenance because if a bound variable type is changed, the local function declaration does not have to change.
]
[important
@@ -156,8 +157,8 @@
This library introduces the new "keyword" `bind`
[footnote
-The token `bind` is not a real keyword of the C++ language.
-This library parses `bind` during macro expansion using preprocessor metaprogramming.
+Obviously, the token `bind` is not a keyword of the C++ language.
+This library parses the token `bind` during macro expansion using preprocessor metaprogramming (see the __Implementation__ section).
Therefore, `bind` can be considered a new "keyword" only at the preprocessor metaprogramming level within the syntax defined by the macros of this library -- thus it is referred to as a "keyword" only within quotes.
]
which is used in place of the parameter type to specify the name of a variable in scope to bind.
@@ -165,27 +166,27 @@
bind ``/variable-name/`` // Bind by value.
-Or by reference if the variable name is prefixed by `&`:
+Or by reference prefixing the variable name with `&`:
bind& ``/variable-name/`` // Bind by reference.
Furthermore, the "keyword" `bind` can be prefixed by `const` to bind the variable by constant value:
- const bind ``/variable-name/`` // Bind by constant value.
+ const bind ``/variable-name/`` // Bind by value.
Or by constant reference:
const bind& ``/variable-name/`` // Bind by constant value.
-Note that when `const` is used, it must always precede `bind`.
+(Note that when `const` is used, it must always precede `bind`.)
If a variable is bound by value, then a copy of the variable value is taken at the point of the local function declaration.
If a variable is bound by reference instead, the variable will refer to the value it has at the point of the local function call.
-Furthermore, it is the programmers' responsibility to ensure that variables bound by reference survive the scope of declaration of the local function otherwise the bound references will be invalid causing run-time errors (in other words, the usual care in using C++ references must be taken for variables bound by reference).
+Furthermore, it is the programmers' responsibility to ensure that variables bound by reference survive the declaration scope of the local function otherwise the bound references will be invalid causing run-time errors (in other words, the usual care in using C++ references must be taken for variables bound by reference).
The type of bound variables is automatically deduced and it is the exact same type used to declare such variables in the enclosing scope.
-Therefore, if a bound variable is declared constant using the `const` qualifier in the enclosing scope then it will be always bound by constant value or reference even if `const` is not repeated by the local function binding.
-On the other hand, if a bound variable was not declared constant by enclosing scope then it will not be bound as constant unless constant binding is forced using `const bind ...` (note that binding by constant reference is not supported by __CPP0x_lambda__ functions).
+Therefore, if a bound variable is declared constant, using the `const` qualifier in the enclosing scope, then it will be always bound by constant value or constant reference even if `const` is not repeated by the local function binding.
+On the other hand, if a bound variable was not declared constant in the enclosing scope then it will not be bound as constant unless constant binding is forced using `const bind ...` (note that binding by constant reference is not supported by __CPP0x_lambda__ functions but it is supported by this library).
[footnote
An historical note: Constant binding of variables in scope was the main use case that originally motivated the authors in developing this library.
The authors needed to locally create a chuck of code to assert some correctness conditions while these assertions were not supposed to modify any of the variables they were using (see the __Contractpp__ library).
@@ -205,7 +206,12 @@
[h5 Binding the Object `this`]
It is also possible to bind the object `this` when it is in scope (e.g., from an enclosing member function).
-This is done by using `this` as the name of the variable to bind and by using the special symbol `this_` (instead of `this`) to access the object within the local function body.
+This is done by using `this` as the name of the variable to bind in the local function declaration and by using the special symbol `this_`
+[footnote
+*Rationale.*
+The special name `this_` was chosen following [@http://boost.2283326.n4.nabble.com/local-this-or-this-td3423912.html Boost practises] which postfix with an underscore identifiers that are named after keywords (the C++ keyword `this` in this case).
+]
+(instead of `this`) to access the object within the local function body.
The object `this` can be bound by value:
@@ -225,21 +231,20 @@
When the object `this` is bound to a local function, the local function body must use the special symbol `this_` (instead of `this`) to access the bound object.
[footnote
*Rationale.*
-This limitation comes from the fact that `this` is a reserved C++ keyword so it cannot be used as the name of the internal parameter passing the bound object to the local function body.
-It would be possible to use `this` (instead of `this_`) within the local function body either at the expenses of copying the bound object (which would introduce run-time overhead and also the stringent requirement that the bound object must have a deep copy constructor) or by relying on an [@http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/d3a86f27277f713b undefined behaviour of `static_cast`] (which might not work on all platforms at the cost of portability).
-Finally, the special name `this_` was chosen following [@http://boost.2283326.n4.nabble.com/local-this-or-this-td3423912.html Boost practise] to postfix with an underscore identifiers that are named after keywords (the C++ keyword `this` in this case).
+This limitation comes from the fact that `this` is a reserved C++ keyword so it cannot be used as the name of the internal parameter that passes the bound object to the local function body.
+It would have been possible to use `this` (instead of `this_`) within the local function body either at the expenses of copying the bound object (which would introduce run-time overhead and also the stringent requirement that the bound object must have a deep copy constructor) or by relying on an [@http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/d3a86f27277f713b undefined behaviour of `static_cast`] (which might not work on all platforms at the cost of portability).
]
Unfortunately, mistakenly using `this` within the local function body instead of `this_` will not necessarily generate a compile-time error.
[footnote
*Rationale.*
-The local function body cannot be a static member function of the local functor object in order to support recursion (because the local function name is specified by the `__BOOST_LOCAL_FUNCTION_NAME__` macro only after the body so it must be made available via a functor member variable named after the local function and local classes cannot have static member variables in C++) and nesting (because the argument binding variable must be declared as a member variable so it is visible in a local function nested within the body member function).
-Therefore, from within the local function body the variable `this` is visible but it refers to the local functor object and not to the bound object.
+The local function body cannot be a static member function of the local functor object in order to support recursion (because the local function name is specified by the `__BOOST_LOCAL_FUNCTION_NAME__` macro only after the body so it must be made available via a functor member variable named after the local function and local classes cannot have static member variables in C++) and nesting (because the argument binding variable must be declared as a member variable so it is visible in a local function nested within the body member function) -- see the __Implementation__ section.
+Therefore, from within the local function body the variable `this` is visible but it refers to the local functor and not to the bound object.
]
Programmers are responsible to make sure that `this` is never used within a local function body which should only use the special symbol `this_`.
]
-For example, let's rewrite a local function `add` similar to the one in the example from the __Introduction__ section but using a member function to illustrate how to bind the object `this`:
+For example, let's program a local function `add` similar to the one in the example from the __Introduction__ section but using a member function to illustrate how to bind the object `this`:
[table
[ [__Variadic_Macro_Syntax__] [__Sequencing_Macro_Syntax__] ]
@@ -266,7 +271,7 @@
These macros expand to code that executes the body instructions "in place" where the block is defined.
Only bound variables specified by [^/bindings/] are accessible from within the local block body.
-Following the same syntax used for local functions, [^['bindings]] can either be empty (using `(void)`, `void`, or an empty macro parameter depending on your compiler extensions, see __Tutorial_Empty_Parameters__), or they can list the variables to bind using the "keyword" `bind` in place of the parameter type, using `const bind` for constant binding, prefixing the bound variable name with `&` to bind by reference, and using `this` to bind the object in scope (see __Tutorial_Binding__).
+Following the same syntax used for local functions, [^['bindings]] can either be empty (using `(void)`, `void`, or an empty macro parameter depending on your compiler, see __Tutorial_Empty_Parameters__), or they can list the variables to bind using the "keyword" `bind` in place of the parameter type, using `const bind` for constant binding, prefixing the bound variable name with `&` to bind by reference, and using `this` to bind the object in scope (see __Tutorial_Binding__).
[important
A `return;` instruction from within a local block jumps to the end of the local block body and it does not return the enclosing function.
@@ -316,7 +321,7 @@
]
Only bound variables specified by [^['bindings]] are accessible from within the local exit body.
-Following the same syntax used for local functions, [^['bindings]] can either be empty (using `(void)`, `void`, or an empty macro parameter depending on your compiler extensions, see __Tutorial_Empty_Parameters__), or they can list the variables to bind using the "keyword" `bind` in place of the parameter type, using `const bind` for constant binding, prefixing the bound variable name with `&` to bind by reference, and using `this` to bind the object in scope (see __Tutorial_Binding__).
+Following the same syntax used for local functions, [^['bindings]] can either be empty (using `(void)`, `void`, or an empty macro parameter depending on your compiler, see __Tutorial_Empty_Parameters__), or they can list the variables to bind using the "keyword" `bind` in place of the parameter type, using `const bind` for constant binding, prefixing the bound variable name with `&` to bind by reference, and using `this` to bind the object in scope (see __Tutorial_Binding__).
[important
A `return;` instruction from within a local exit jumps to the end of the local exit body and it does not return the enclosing function.
@@ -335,10 +340,10 @@
This library could be merged together with __Boost_ScopeExit__ into a new library named Boost.Scope (from the meaning of the word "[@http://en.wikipedia.org/wiki/Scope_(programming) scope]" in computer programming).
This would be justified by the fact that `__BOOST_LOCAL_EXIT__` simply extends the functionality already provided by `BOOST_SCOPE_EXIT`.
The headers will be `"boost/scope/function.hpp"`, `"boost/scope/block.hpp"`, and `"boost/scope/exit.hpp"` (for backward compatibility with __Boost_ScopeExit__, the header `"boost/scope_exit.hpp"` could also be kept and it would be equivalent to including `"boost/scope/exit.hpp"`).
-However, the new `BOOST_SCOPE_EXIT` macro will not be backward compatible with the current __Boost_ScopeExit__ macro because it will require to prefix the bound variable with `bind` or `const bind` (in order to differentiate from constant and non-constant binding).
+However, the new `BOOST_SCOPE_EXIT` macro will not be backward compatible with the current __Boost_ScopeExit__ macro because it will require to prefix the bound variable with `bind` or `const bind` (in order to differentiate from constant and non-constant binding and to prevent the bound tokens from ever starting with a non-alphanumeric symbol like `&`).
Local blocks would be named "scope blocks" and they would be provided by the `BOOST_SCOPE_BLOCK...` macros (the "scope block" name seems reasonably expressive).
However, local functions would have to be named "scope functions" and they would be provided by the `BOOST_SCOPE_FUNCTION...` macros.
-This name might not expressive enough because local functions are not known under the name of "scope functions" -- they are indeed known by either the name of "local functions" or by the name of "[@http://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html nested functions]" (GCC compiler extension).
+This name might not be expressive enough because local functions are not known under the name of "scope functions" -- they are indeed known by either the name of "local functions" or by the name of "[@http://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html nested functions]" (GCC compiler extension).
]
Local exits can be used to emulate the __D_Programming_Language__ /scope guards/ (see the __Examples_Emulating_Ds_Scope_Guards__ example).
Modified: sandbox/local/libs/local/example/add_block.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_block.cpp (original)
+++ sandbox/local/libs/local/example/add_block.cpp 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -12,13 +12,14 @@
int main() {
double sum = 1975.0;
- BOOST_LOCAL_BLOCK( (const bind& sum) ) {
+ BOOST_LOCAL_BLOCK( (const bind& sum) ) { // Local block.
assert(sum == 1975.0); // OK: Complier error if `==` confused with `=`.
std::cout << "Asserted summation: " << sum << std::endl;
return; // Return this local block (and not the enclosing scope).
assert(false); // OK: Never executed.
} BOOST_LOCAL_BLOCK_END
+ // Local block executed here.
return 0;
}
Modified: sandbox/local/libs/local/example/add_block_va.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_block_va.cpp (original)
+++ sandbox/local/libs/local/example/add_block_va.cpp 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -21,13 +21,14 @@
int main() {
double sum = 1975.0;
- BOOST_LOCAL_BLOCK(const bind& sum) {
+ BOOST_LOCAL_BLOCK(const bind& sum) { // Local block.
assert(sum == 1975.0); // OK: Complier error if `==` confused with `=`.
std::cout << "Asserted summation: " << sum << std::endl;
return; // Return this local block (and not the enclosing scope).
assert(false); // OK: Never executed.
} BOOST_LOCAL_BLOCK_END
+ // Local block executed here.
return 0;
}
Modified: sandbox/local/libs/local/example/add_exit.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_exit.cpp (original)
+++ sandbox/local/libs/local/example/add_exit.cpp 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -13,7 +13,7 @@
size_t size = 2;
double* nums = new double[size];
- BOOST_LOCAL_EXIT( (const bind& size) (bind nums) ) {
+ BOOST_LOCAL_EXIT( (const bind& size) (bind nums) ) { // Local exit.
if (size && nums) delete[] nums;
std::cout << "Freed array: " << nums << std::endl;
@@ -22,6 +22,6 @@
} BOOST_LOCAL_EXIT_END
return 0;
-}
+} // Local exit executed here.
//]
Modified: sandbox/local/libs/local/example/add_exit_va.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_exit_va.cpp (original)
+++ sandbox/local/libs/local/example/add_exit_va.cpp 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -22,7 +22,7 @@
size_t size = 2;
double* nums = new double[size];
- BOOST_LOCAL_EXIT(const bind& size, bind nums) {
+ BOOST_LOCAL_EXIT(const bind& size, bind nums) { // Local exit.
if (size && nums) delete[] nums;
std::cout << "Freed array: " << nums << std::endl;
@@ -31,7 +31,7 @@
} BOOST_LOCAL_EXIT_END
return 0;
-}
+} // Local exit executed here.
//]
#endif
Modified: sandbox/local/libs/local/example/add_function.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_function.cpp (original)
+++ sandbox/local/libs/local/example/add_function.cpp 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -13,7 +13,7 @@
int factor = 10;
void BOOST_LOCAL_FUNCTION_PARAMS( (double num) (const bind factor)
- (bind& sum) ) {
+ (bind& sum) ) { // Bind `factor` and `sum`.
sum += factor * num;
std::cout << "Summed: " << sum << std::endl;
} BOOST_LOCAL_FUNCTION_NAME(add)
Modified: sandbox/local/libs/local/example/add_function_va.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_function_va.cpp (original)
+++ sandbox/local/libs/local/example/add_function_va.cpp 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -22,7 +22,7 @@
int factor = 10;
void BOOST_LOCAL_FUNCTION_PARAMS(double num, const bind factor,
- bind& sum) {
+ bind& sum) { // Bind `factor` and `sum`.
sum += factor * num;
std::cout << "Summed: " << sum << std::endl;
} BOOST_LOCAL_FUNCTION_NAME(add)
Modified: sandbox/local/libs/local/example/add_template.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_template.cpp (original)
+++ sandbox/local/libs/local/example/add_template.cpp 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -17,6 +17,7 @@
int factor = 10;
// Use `..._TPL()` macros within templates.
+
T BOOST_LOCAL_FUNCTION_PARAMS_TPL( (T num) (const bind factor)
(bind& sum) ) {
return sum += factor * num;
Modified: sandbox/local/libs/local/example/add_template_va.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_template_va.cpp (original)
+++ sandbox/local/libs/local/example/add_template_va.cpp 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -26,6 +26,7 @@
int factor = 10;
// Use `..._TPL()` macros within templates.
+
void BOOST_LOCAL_FUNCTION_PARAMS_TPL(T num, const bind factor,
bind& sum) {
sum += factor * num;
Modified: sandbox/local/libs/local/example/add_this.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_this.cpp (original)
+++ sandbox/local/libs/local/example/add_this.cpp 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -19,7 +19,7 @@
double sum(const std::vector<double>& nums, const int& factor = 10) {
void BOOST_LOCAL_FUNCTION_PARAMS( (double num) (const bind factor)
- (bind this) ) {
+ (bind this) ) { // Bind `this`.
this_->sum_ += factor * num; // Use `this_` instead of `this`.
std::cout << "Summed: " << this_->sum_ << std::endl;
} BOOST_LOCAL_FUNCTION_NAME(add)
Modified: sandbox/local/libs/local/example/add_this_va.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_this_va.cpp (original)
+++ sandbox/local/libs/local/example/add_this_va.cpp 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -28,7 +28,7 @@
double sum(const std::vector<double>& nums, const int& factor = 10) {
void BOOST_LOCAL_FUNCTION_PARAMS(double num, const bind factor,
- bind this) {
+ bind this) { // Bind `this`.
this_->sum_ += factor * num; // Use `this_` instead of `this`.
std::cout << "Summed: " << this_->sum_ << std::endl;
} BOOST_LOCAL_FUNCTION_NAME(add)
Modified: sandbox/local/libs/local/example/add_x_y.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_x_y.cpp (original)
+++ sandbox/local/libs/local/example/add_x_y.cpp 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -9,11 +9,11 @@
#include <iostream>
int main() {
- int BOOST_LOCAL_FUNCTION_PARAMS( (int x) (int y) ) {
+ int BOOST_LOCAL_FUNCTION_PARAMS( (int x) (int y) ) { // Local function.
return x + y;
} BOOST_LOCAL_FUNCTION_NAME(add)
- std::cout << add(1, 2) << std::endl;
+ std::cout << add(1, 2) << std::endl; // Call local function.
return 0;
}
//]
Modified: sandbox/local/libs/local/example/add_x_y_default.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_x_y_default.cpp (original)
+++ sandbox/local/libs/local/example/add_x_y_default.cpp 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -9,7 +9,7 @@
#include <iostream>
int main() {
- int BOOST_LOCAL_FUNCTION_PARAMS( (int x) (int y)(default 2) ) {
+ int BOOST_LOCAL_FUNCTION_PARAMS( (int x) (int y)(default 2) ) { // Default.
return x + y;
} BOOST_LOCAL_FUNCTION_NAME(add)
Modified: sandbox/local/libs/local/example/add_x_y_default_va.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_x_y_default_va.cpp (original)
+++ sandbox/local/libs/local/example/add_x_y_default_va.cpp 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -18,7 +18,7 @@
#include <iostream>
int main() {
- int BOOST_LOCAL_FUNCTION_PARAMS(int x, int y, default 2) {
+ int BOOST_LOCAL_FUNCTION_PARAMS(int x, int y, default 2) { // Default.
return x + y;
} BOOST_LOCAL_FUNCTION_NAME(add)
Modified: sandbox/local/libs/local/example/add_x_y_default_with_va.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_x_y_default_with_va.cpp (original)
+++ sandbox/local/libs/local/example/add_x_y_default_with_va.cpp 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -20,7 +20,7 @@
#define WITH_DEFAULT , default
int main() {
- int BOOST_LOCAL_FUNCTION_PARAMS(int x, int y WITH_DEFAULT 2) {
+ int BOOST_LOCAL_FUNCTION_PARAMS(int x, int y WITH_DEFAULT 2) { // Default.
return x + y;
} BOOST_LOCAL_FUNCTION_NAME(add)
Modified: sandbox/local/libs/local/example/add_x_y_va.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_x_y_va.cpp (original)
+++ sandbox/local/libs/local/example/add_x_y_va.cpp 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -18,11 +18,11 @@
#include <iostream>
int main() {
- int BOOST_LOCAL_FUNCTION_PARAMS(int x, int y) {
+ int BOOST_LOCAL_FUNCTION_PARAMS(int x, int y) { // Local function.
return x + y;
} BOOST_LOCAL_FUNCTION_NAME(add)
- std::cout << add(1, 2) << std::endl;
+ std::cout << add(1, 2) << std::endl; // Call local function.
return 0;
}
//]
Modified: sandbox/local/libs/local/example/ten.cpp
==============================================================================
--- sandbox/local/libs/local/example/ten.cpp (original)
+++ sandbox/local/libs/local/example/ten.cpp 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -9,7 +9,7 @@
#include <iostream>
int main() {
- int BOOST_LOCAL_FUNCTION_PARAMS( (void) ) {
+ int BOOST_LOCAL_FUNCTION_PARAMS( (void) ) { // No parameter.
return 10;
} BOOST_LOCAL_FUNCTION_NAME(ten)
Modified: sandbox/local/libs/local/example/ten_ep.cpp
==============================================================================
--- sandbox/local/libs/local/example/ten_ep.cpp (original)
+++ sandbox/local/libs/local/example/ten_ep.cpp 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -18,7 +18,7 @@
#include <iostream>
int main() {
- int BOOST_LOCAL_FUNCTION_PARAMS() {
+ int BOOST_LOCAL_FUNCTION_PARAMS() { // No parameter.
return 10;
} BOOST_LOCAL_FUNCTION_NAME(ten)
Modified: sandbox/local/libs/local/example/ten_va.cpp
==============================================================================
--- sandbox/local/libs/local/example/ten_va.cpp (original)
+++ sandbox/local/libs/local/example/ten_va.cpp 2011-05-04 23:11:27 EDT (Wed, 04 May 2011)
@@ -18,7 +18,7 @@
#include <iostream>
int main() {
- int BOOST_LOCAL_FUNCTION_PARAMS(void) {
+ int BOOST_LOCAL_FUNCTION_PARAMS(void) { // No parameter.
return 10;
} BOOST_LOCAL_FUNCTION_NAME(ten)
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk