|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69340 - in sandbox/local: boost/local/aux_ boost/local/aux_/function_macros/code_ libs/local/doc/html libs/local/doc/html/boost/local libs/local/doc/html/boost_local libs/local/doc/qbk libs/local/example
From: lorcaminiti_at_[hidden]
Date: 2011-02-27 12:35:56
Author: lcaminiti
Date: 2011-02-27 12:35:43 EST (Sun, 27 Feb 2011)
New Revision: 69340
URL: http://svn.boost.org/trac/boost/changeset/69340
Log:
Fixed result type deduction to work with templates on GCC (using function ptr and Boost.ScopeExit type tagging/wrapping/etc).
Text files modified:
sandbox/local/boost/local/aux_/function_macros/code_/deduce_result_type.hpp | 36 +++++++++++--
sandbox/local/boost/local/aux_/symbol.hpp | 18 ++++++
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_END.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_END.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT_TPL.html | 2
sandbox/local/libs/local/doc/html/boost/local/function.html | 2
sandbox/local/libs/local/doc/html/boost_local/Advanced.html | 107 +++++++--------------------------------
sandbox/local/libs/local/doc/html/boost_local/Grammar.html | 6 +-
sandbox/local/libs/local/doc/html/boost_local/Rationale.html | 8 +-
sandbox/local/libs/local/doc/html/boost_local/Tutorial.html | 38 +++++++-------
sandbox/local/libs/local/doc/html/index.html | 2
sandbox/local/libs/local/doc/html/reference.html | 2
sandbox/local/libs/local/doc/qbk/local.qbk | 2
sandbox/local/libs/local/example/add_template.cpp | 26 ++++----
18 files changed, 117 insertions(+), 144 deletions(-)
Modified: sandbox/local/boost/local/aux_/function_macros/code_/deduce_result_type.hpp
==============================================================================
--- sandbox/local/boost/local/aux_/function_macros/code_/deduce_result_type.hpp (original)
+++ sandbox/local/boost/local/aux_/function_macros/code_/deduce_result_type.hpp 2011-02-27 12:35:43 EST (Sun, 27 Feb 2011)
@@ -3,17 +3,41 @@
#define BOOST_LOCAL_AUX_FUNCTION_CODE_DEDUCE_RESULT_TYPE_HPP_
#include "../../symbol.hpp"
-// Use this lib's ScopeExit impl (for TYPEOF).
-#include "../../scope_exit/scope_exit.hpp"
+#include "../../scope_exit/scope_exit.hpp" // Use this lib's ScopeExit impl.
#include <boost/type_traits.hpp>
+#include <boost/preprocessor/control/iif.hpp>
+#include <boost/preprocessor/facilities/is_empty.hpp>
// This must follow the result type.
#define BOOST_LOCAL_AUX_FUNCTION_CODE_DEDUCE_RESULT_TYPE( \
id, typename_keyword) \
- /* declare function expr with preceeding result type and no param */ \
- /* result type here */ (BOOST_LOCAL_AUX_SYMBOL_DEDUCE_RESULT_TYPE(id))();\
- typedef typename_keyword ::boost::function_traits<BOOST_TYPEOF( \
- BOOST_LOCAL_AUX_SYMBOL_DEDUCE_RESULT_TYPE(id))>::result_type \
+ /* result type here */ (*BOOST_LOCAL_AUX_SYMBOL_DEDUCE_RESULT_FUNC(id))(); \
+ /* the many tagging, wrapping, etc that follow are taken from */ \
+ /* Boost.ScopeExit type deduction mechanism and they are necessary */ \
+ /* within template on GCC to work around a compiler internal error */ \
+ typedef void (*BOOST_LOCAL_AUX_SYMBOL_DEDUCE_RESULT_TAG(id))( \
+ int BOOST_LOCAL_AUX_SYMBOL_DEDUCE_RESULT_FUNC(id)); \
+ typedef BOOST_PP_IIF(BOOST_PP_IS_EMPTY(typename_keyword), \
+ BOOST_TYPEOF \
+ , \
+ BOOST_TYPEOF_TPL \
+ )(boost::scope_exit::aux::wrap( \
+ boost::scope_exit::aux::deref( \
+ BOOST_LOCAL_AUX_SYMBOL_DEDUCE_RESULT_FUNC(id), \
+ (BOOST_LOCAL_AUX_SYMBOL_DEDUCE_RESULT_TAG(id))0))) \
+ BOOST_LOCAL_AUX_SYMBOL_DEDUCE_RESULT_WRAP(id); \
+ typedef typename_keyword BOOST_LOCAL_AUX_SYMBOL_DEDUCE_RESULT_WRAP(id):: \
+ type BOOST_LOCAL_AUX_SYMBOL_DEDUCE_RESULT_CAPTURE(id); \
+ struct BOOST_LOCAL_AUX_SYMBOL_DEDUCE_RESULT_PARAMS(id) { \
+ typedef BOOST_LOCAL_AUX_SYMBOL_DEDUCE_RESULT_CAPTURE(id) \
+ function_ptr_type;\
+ }; \
+ typedef typename_keyword boost::remove_pointer<typename_keyword \
+ BOOST_LOCAL_AUX_SYMBOL_DEDUCE_RESULT_PARAMS(id):: \
+ function_ptr_type>::type \
+ BOOST_LOCAL_AUX_SYMBOL_DEDUCE_RESULT_FUNC_TYPE(id); \
+ typedef typename_keyword boost::function_traits< \
+ BOOST_LOCAL_AUX_SYMBOL_DEDUCE_RESULT_FUNC_TYPE(id)>::result_type \
BOOST_LOCAL_AUX_SYMBOL_RESULT_TYPE(id);
#endif // #include guard
Modified: sandbox/local/boost/local/aux_/symbol.hpp
==============================================================================
--- sandbox/local/boost/local/aux_/symbol.hpp (original)
+++ sandbox/local/boost/local/aux_/symbol.hpp 2011-02-27 12:35:43 EST (Sun, 27 Feb 2011)
@@ -36,10 +36,26 @@
BOOST_PP_CAT(BOOST_PP_CAT(name, BOOST_LOCAL_AUX_SYMBOL_INFIX), \
BOOST_LOCAL_AUX_INTERNAL_SYMBOL(typeof_type))
-#define BOOST_LOCAL_AUX_SYMBOL_DEDUCE_RESULT_TYPE(id) \
+#define BOOST_LOCAL_AUX_SYMBOL_DEDUCE_RESULT_FUNC(id) \
/* symbol (not internal) also gives error if missing result type */ \
BOOST_PP_CAT(ERROR_missing_result_type_before_the_local_function_parameter_macro_id, id)
+#define BOOST_LOCAL_AUX_SYMBOL_DEDUCE_RESULT_TAG(id) \
+ BOOST_LOCAL_AUX_INTERNAL_SYMBOL(BOOST_PP_CAT(deduce_result_tag, id))
+
+#define BOOST_LOCAL_AUX_SYMBOL_DEDUCE_RESULT_WRAP(id) \
+ BOOST_LOCAL_AUX_INTERNAL_SYMBOL(BOOST_PP_CAT(deduce_result_wrap, id))
+
+#define BOOST_LOCAL_AUX_SYMBOL_DEDUCE_RESULT_CAPTURE(id) \
+ BOOST_LOCAL_AUX_INTERNAL_SYMBOL(BOOST_PP_CAT(deduce_result_capture, id))
+
+#define BOOST_LOCAL_AUX_SYMBOL_DEDUCE_RESULT_PARAMS(id) \
+ BOOST_LOCAL_AUX_INTERNAL_SYMBOL(BOOST_PP_CAT(deduce_result_params, id))
+
+#define BOOST_LOCAL_AUX_SYMBOL_DEDUCE_RESULT_FUNC_TYPE(id) \
+ BOOST_LOCAL_AUX_INTERNAL_SYMBOL(BOOST_PP_CAT(deduce_result_function_type, \
+ id))
+
#define BOOST_LOCAL_AUX_SYMBOL_RESULT_TYPE(id) \
BOOST_LOCAL_AUX_INTERNAL_SYMBOL(BOOST_PP_CAT(result_type, id))
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-02-27 12:35:43 EST (Sun, 27 Feb 2011)
@@ -33,7 +33,7 @@
</span>BOOST_IDENTITY_TYPE(parenthesized_type)</pre></div>
<div class="refsect1">
-<a name="id890339"></a><h2>Description</h2>
+<a name="id888292"></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.html" title="Advanced">Advanced</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-02-27 12:35:43 EST (Sun, 27 Feb 2011)
@@ -33,7 +33,7 @@
</span>BOOST_IDENTITY_VALUE(parenthesized_value)</pre></div>
<div class="refsect1">
-<a name="id890479"></a><h2>Description</h2>
+<a name="id888432"></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.html" title="Advanced">Advanced</a> section).</p>
<p>For example <code class="computeroutput">BOOST_IDENTITY_VALUE((key_size<int, double>::value))</code> can be passed as a single macro parameter when instead <code class="computeroutput">key_size<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_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-02-27 12:35:43 EST (Sun, 27 Feb 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_BLOCK_END</pre></div>
<div class="refsect1">
-<a name="id888282"></a><h2>Description</h2>
+<a name="id886235"></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">CONTRACT_DETAIL_LOCAL_BLOCK</code> documentation.</p>
<p><span class="bold"><strong>See:</strong></span> <code class="computeroutput">CONTRACT_DETAIL_LOCAL_BLOCK</code>, <a class="link" href="boost_local/Tutorial.html" title="Tutorial">Tutorial</a> section. </p>
</div>
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-02-27 12:35:43 EST (Sun, 27 Feb 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_CONFIG_FUNCTION_ARITY_MAX</pre></div>
<div class="refsect1">
-<a name="id888414"></a><h2>Description</h2>
+<a name="id886367"></a><h2>Description</h2>
<p><span class="bold"><strong>Note:</strong></span> If programmers leave this 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-02-27 12:35:43 EST (Sun, 27 Feb 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_CONFIG_THIS_PARAM_NAME</pre></div>
<div class="refsect1">
-<a name="id888513"></a><h2>Description</h2>
+<a name="id886467"></a><h2>Description</h2>
<p><span class="bold"><strong>Note:</strong></span> If programmers leave this 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/Starting.html" title="Starting">Starting</a> section. </p>
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-02-27 12:35:43 EST (Sun, 27 Feb 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_EXIT_END</pre></div>
<div class="refsect1">
-<a name="id888737"></a><h2>Description</h2>
+<a name="id886690"></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">CONTRACT_DETAIL_LOCAL_EXIT</code> documentation.</p>
<p><span class="bold"><strong>See:</strong></span> <code class="computeroutput">CONTRACT_DETAIL_LOCAL_EXIT</code>, <a class="link" href="boost_local/Tutorial.html" title="Tutorial">Tutorial</a> section. </p>
</div>
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-02-27 12:35:43 EST (Sun, 27 Feb 2011)
@@ -31,7 +31,7 @@
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: <<a class="link" href="reference.html#header.boost.local.exit_hpp" title="Header <boost/local/exit.hpp>">boost/local/exit.hpp</a>>
-</span>BOOST_LOCAL_EXIT_TPL(binding_list)</pre></div>
+</span>BOOST_LOCAL_EXIT_TPL(...)</pre></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
Modified: sandbox/local/libs/local/doc/html/boost/local/function.html
==============================================================================
--- sandbox/local/libs/local/doc/html/boost/local/function.html (original)
+++ sandbox/local/libs/local/doc/html/boost/local/function.html 2011-02-27 12:35:43 EST (Sun, 27 Feb 2011)
@@ -35,7 +35,7 @@
<span class="keyword">struct</span> <a class="link" href="function.html" title="Struct template function">function</a> <span class="special">{</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
-<a name="id889078"></a><h2>Description</h2>
+<a name="id887031"></a><h2>Description</h2>
<p>This template defines several specializations to handle a generic number <code class="computeroutput">N</code> of function parameters some of which can have default values. The number of supported function parameters goes from <code class="computeroutput">0</code> (for a function with no parameter) to a maximum of <code class="computeroutput"><a class="link" href="../../BOOST_LOCAL_CONFIG_FUNCTION_ARITY_MAX.html" title="Macro BOOST_LOCAL_CONFIG_FUNCTION_ARITY_MAX">BOOST_LOCAL_CONFIG_FUNCTION_ARITY_MAX</a></code>.</p>
<p>Each template specialization defines call operators <code class="computeroutput">operator()(...)</code> with a different set of parameters to handle the number of default parameters specified by <code class="computeroutput">defaults</code> (see <a class="link" href="../../boost_local/Advanced.html" title="Advanced">Advanced</a> section): </p>
<pre class="programlisting"> <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">Result</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Arg1</span><span class="special">,</span> <span class="special">...</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">ArgN</span><span class="special">,</span> <span class="identifier">size_t</span> <span class="identifier">defaults</span> <span class="special">=</span> <span class="number">0</span><span class="special">></span>
Modified: sandbox/local/libs/local/doc/html/boost_local/Advanced.html
==============================================================================
--- sandbox/local/libs/local/doc/html/boost_local/Advanced.html (original)
+++ sandbox/local/libs/local/doc/html/boost_local/Advanced.html 2011-02-27 12:35:43 EST (Sun, 27 Feb 2011)
@@ -194,7 +194,7 @@
</span> <span class="special">)</span>
</pre>
<p>
- Consider the following complete example: <sup>[<a name="id876783" href="#ftn.id876783" class="footnote">15</a>]</sup>
+ Consider the following complete example: <sup>[<a name="id876264" href="#ftn.id876264" class="footnote">15</a>]</sup>
</p>
<p>
@@ -213,11 +213,11 @@
<span class="keyword">typedef</span> <span class="keyword">int</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">sign_t</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">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span>
+ <span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS</span><span class="special">(</span>
<span class="comment">// Identity macors handle commas.
</span> <span class="special">(</span><span class="identifier">BOOST_IDENTITY_TYPE</span><span class="special">((</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">size_t</span><span class="special">>))&</span> <span class="identifier">m</span><span class="special">)</span>
<span class="special">(</span><span class="keyword">const</span> <span class="identifier">size_t</span><span class="special">&</span> <span class="identifier">factor</span><span class="special">)(</span><span class="keyword">default</span> <span class="comment">// Or just use `(default (...))`.
-</span> <span class="identifier">BOOST_IDENITY_VALUE</span><span class="special">((</span><span class="identifier">key_size</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">size_t</span><span class="special">>::</span><span class="identifier">value</span><span class="special">)))</span>
+</span> <span class="identifier">BOOST_IDENTITY_VALUE</span><span class="special">((</span><span class="identifier">key_size</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">size_t</span><span class="special">>::</span><span class="identifier">value</span><span class="special">)))</span>
<span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&</span> <span class="identifier">separator</span><span class="special">)(</span><span class="keyword">default</span> <span class="identifier">cat</span><span class="special">(</span><span class="string">":"</span><span class="special">,</span> <span class="string">" "</span><span class="special">))</span>
<span class="comment">// Also, identity macors handle leading symbols.
</span> <span class="special">(</span><span class="identifier">BOOST_IDENTITY_TYPE</span><span class="special">((::</span><span class="identifier">sign_t</span><span class="special">))</span> <span class="identifier">sign</span><span class="special">)(</span><span class="keyword">default</span> <span class="special">-</span><span class="number">1</span><span class="special">)</span> <span class="special">)</span> <span class="special">{</span>
@@ -409,7 +409,7 @@
Local functions are never copied by value. You can only obtain a reference
to a local function therefore you need to make sure that the <span class="bold"><strong>local function survives the scope of its reference</strong></span>
otherwise the reference will be invalid and its use will generate a run-time
- error (as usual with C++ references). <sup>[<a name="id881059" href="#ftn.id881059" class="footnote">16</a>]</sup>
+ error (as usual with C++ references). <sup>[<a name="id880541" href="#ftn.id880541" class="footnote">16</a>]</sup>
</p></td></tr>
</table></div>
<p>
@@ -528,7 +528,7 @@
Where the <span class="emphasis"><em>new-local-function-name</em></span> no longer has to match
the local function name as originally specified in the parenthesized signature
passed to <code class="computeroutput">BOOST_LOCAL_FUNCTION</code>.
- For example: <sup>[<a name="id883574" href="#ftn.id883574" class="footnote">17</a>]</sup>
+ For example: <sup>[<a name="id883056" href="#ftn.id883056" class="footnote">17</a>]</sup>
</p>
<pre class="programlisting"><span class="special">{</span>
<code class="computeroutput">BOOST_LOCAL_FUNCTION</code><span class="special">(</span>
@@ -556,36 +556,10 @@
then passing the reference as template parameter. For example:
</p>
<p>
-
-</p>
-<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">local</span><span class="special">/</span><span class="identifier">function</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
-<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">local</span><span class="special">/</span><span class="identifier">function_ref</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
-<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span>
-<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="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span>
- <span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">(</span><span class="identifier">print</span><span class="special">)(</span> <span class="special">(</span><span class="keyword">int</span><span class="special">)(</span><span class="identifier">x</span><span class="special">)</span> <span class="special">)</span>
- <span class="special">)</span> <span class="special">{</span>
- <span class="comment">// Only original `print` name available within local function body.
-</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">x</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_END_RENAME</span><span class="special">(</span><span class="identifier">new_print</span><span class="special">)</span>
- <span class="comment">// Only new `new_print` name available within enclosing scope.
-</span>
- <span class="keyword">int</span> <span class="identifier">a</span><span class="special">[</span><span class="number">3</span><span class="special">]</span> <span class="special">=</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="number">3</span><span class="special">};</span>
-
- <span class="comment">// std::for_each(a, a + 3, new_print); // Error: Passing renamed function.
-</span>
- <span class="identifier">boost</span><span class="special">::</span><span class="identifier">local</span><span class="special">::</span><span class="identifier">function_ref</span><span class="special"><</span> <span class="keyword">void</span> <span class="special">(</span><span class="keyword">int</span><span class="special">)</span> <span class="special">></span> <span class="identifier">print_ref</span> <span class="special">=</span> <span class="identifier">new_print</span><span class="special">;</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">a</span> <span class="special">+</span> <span class="number">3</span><span class="special">,</span> <span class="identifier">print_ref</span><span class="special">);</span> <span class="comment">// OK: Passing function reference.
-</span>
- <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
-<span class="special">}</span>
-</pre>
-<p>
+ [renamed_print_cpp]
</p>
<a name="boost_local.Advanced.renaming_local_functions.motivation"></a><h6>
-<a name="id884494"></a>
+<a name="id883353"></a>
<a class="link" href="Advanced.html#boost_local.Advanced.renaming_local_functions.motivation">Motivation</a>
</h6>
<p>
@@ -600,46 +574,7 @@
a simple version of the local exit macros using a renamed local function:
</p>
<p>
-
-</p>
-<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">local</span><span class="special">/</span><span class="identifier">function</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
-<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">local</span><span class="special">/</span><span class="identifier">function_ref</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
-<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">preprocessor</span><span class="special">/</span><span class="identifier">cat</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
-
-<span class="preprocessor">#define</span> <span class="identifier">EXIT</span><span class="special">(</span><span class="identifier">parenthesized_binding</span><span class="special">)</span> <span class="special">\</span>
- <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span> <span class="special">\</span>
- <span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">(</span><span class="identifier">BOOST_PP_CAT</span><span class="special">(</span><span class="identifier">exit_code</span><span class="special">,</span> <span class="identifier">__LINE__</span><span class="special">))(</span> <span class="identifier">parenthesized_binding</span> <span class="special">)</span> <span class="special">\</span>
- <span class="special">)</span> <span class="comment">/* followed by exit body here */</span>
-
-<span class="comment">// Local function renaming is necessary because `__LINE__` has a different
-</span><span class="comment">// value when `EXIT_END` macro expands respect to its value when the `EXIT()`
-</span><span class="comment">// macro expands.
-</span><span class="preprocessor">#define</span> <span class="identifier">EXIT_END</span> <span class="special">\</span>
- <span class="comment">/* preceded by exit body here */</span> <span class="special">\</span>
- <span class="identifier">BOOST_LOCAL_FUNCTION_END_RENAME</span><span class="special">(</span> <span class="special">\</span>
- <span class="identifier">BOOST_PP_CAT</span><span class="special">(</span><span class="identifier">exit_code</span><span class="special">,</span> <span class="identifier">__LINE__</span><span class="special">))</span> <span class="special">\</span>
- <span class="identifier">exit_guard</span> <span class="identifier">BOOST_PP_CAT</span><span class="special">(</span><span class="identifier">exit_guardian</span><span class="special">,</span> <span class="identifier">__LINE__</span><span class="special">)(</span> <span class="special">\</span>
- <span class="identifier">BOOST_PP_CAT</span><span class="special">(</span><span class="identifier">exit_code</span><span class="special">,</span> <span class="identifier">__LINE__</span><span class="special">));</span>
-
-<span class="keyword">struct</span> <span class="identifier">exit_guard</span> <span class="special">{</span>
- <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">local</span><span class="special">::</span><span class="identifier">function_ref</span><span class="special"><</span> <span class="keyword">void</span> <span class="special">()</span> <span class="special">></span> <span class="identifier">ref_type</span><span class="special">;</span>
- <span class="keyword">explicit</span> <span class="identifier">exit_guard</span><span class="special">(</span><span class="identifier">ref_type</span> <span class="identifier">ref</span><span class="special">):</span> <span class="identifier">ref_</span><span class="special">(</span><span class="identifier">ref</span><span class="special">)</span> <span class="special">{}</span>
- <span class="special">~</span><span class="identifier">exit_guard</span><span class="special">()</span> <span class="special">{</span> <span class="identifier">ref_</span><span class="special">();</span> <span class="special">}</span> <span class="comment">// Execute local function code at scope exit.
-</span><span class="keyword">private</span><span class="special">:</span>
- <span class="identifier">ref_type</span> <span class="identifier">ref_</span><span class="special">;</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="special">*</span> <span class="identifier">a</span> <span class="special">=</span> <span class="keyword">new</span> <span class="keyword">int</span><span class="special">[</span><span class="number">3</span><span class="special">];</span>
- <span class="identifier">EXIT</span><span class="special">(</span> <span class="special">(</span><span class="identifier">bind</span><span class="special">)((</span><span class="identifier">a</span><span class="special">))</span> <span class="special">)</span> <span class="special">{</span>
- <span class="comment">// Body outside macros so retain complier error meaning.
-</span> <span class="keyword">if</span> <span class="special">(</span><span class="identifier">a</span><span class="special">)</span> <span class="keyword">delete</span><span class="special">[]</span> <span class="identifier">a</span><span class="special">;</span>
- <span class="special">}</span> <span class="identifier">EXIT_END</span>
-
- <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
-<span class="special">}</span>
-</pre>
-<p>
+ [renamed_exit_cpp]
</p>
</div>
<div class="section">
@@ -652,14 +587,14 @@
to usual features of C++ functions.
</p>
<a name="boost_local.Advanced.limitations__overloading__nesting__operators__etc.overloading"></a><h6>
-<a name="id885485"></a>
+<a name="id883437"></a>
<a class="link" href="Advanced.html#boost_local.Advanced.limitations__overloading__nesting__operators__etc.overloading">Overloading</a>
</h6>
<p>
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="id885504" href="#ftn.id885504" class="footnote">18</a>]</sup>
+ parameters). <sup>[<a name="id883457" href="#ftn.id883457" class="footnote">18</a>]</sup>
</p>
<p>
For example, the following code will <span class="bold"><strong>not</strong></span>
@@ -682,12 +617,12 @@
<span class="special">}</span>
</pre>
<a name="boost_local.Advanced.limitations__overloading__nesting__operators__etc.nesting"></a><h6>
-<a name="id885946"></a>
+<a name="id883899"></a>
<a class="link" href="Advanced.html#boost_local.Advanced.limitations__overloading__nesting__operators__etc.nesting">Nesting</a>
</h6>
<p>
It is not possible to nest local functions, local blocks, or local exits
- within each other. Nesting will generate a compile-time error. <sup>[<a name="id885968" href="#ftn.id885968" class="footnote">19</a>]</sup>
+ within each other. Nesting will generate a compile-time error. <sup>[<a name="id883921" href="#ftn.id883921" class="footnote">19</a>]</sup>
</p>
<p>
For example, the following code will <span class="bold"><strong>not</strong></span>
@@ -710,12 +645,12 @@
<span class="special">}</span>
</pre>
<a name="boost_local.Advanced.limitations__overloading__nesting__operators__etc.operators"></a><h6>
-<a name="id886368"></a>
+<a name="id884322"></a>
<a class="link" href="Advanced.html#boost_local.Advanced.limitations__overloading__nesting__operators__etc.operators">Operators</a>
</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="id886406" href="#ftn.id886406" class="footnote">20</a>]</sup>
+ will generate a compile-time error. <sup>[<a name="id884359" href="#ftn.id884359" class="footnote">20</a>]</sup>
</p>
<p>
For example, the following code will <span class="bold"><strong>not</strong></span>
@@ -737,7 +672,7 @@
<span class="special">}</span>
</pre>
<a name="boost_local.Advanced.limitations__overloading__nesting__operators__etc.etc"></a><h6>
-<a name="id886800"></a>
+<a name="id884753"></a>
<a class="link" href="Advanced.html#boost_local.Advanced.limitations__overloading__nesting__operators__etc.etc">Etc</a>
</h6>
<p>
@@ -1042,39 +977,39 @@
</div>
<div class="footnotes">
<br><hr width="100" align="left">
-<div class="footnote"><p><sup>[<a id="ftn.id876783" href="#id876783" class="para">15</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id876264" href="#id876264" class="para">15</a>] </sup>
We 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 parenthesized syntax. However, parenthesized signatures usually
do not contain unwrapped commas "<code class="computeroutput"><span class="special">,</span></code>"
(unless template metaprogramming is being used).
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id881059" href="#id881059" class="para">16</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id880541" href="#id880541" class="para">16</a>] </sup>
The suffix <code class="computeroutput"><span class="identifier">ref</span></code> of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">local</span><span class="special">::</span>function_ref</code> is meant
to help programmers remember that they are dealing with references to
(and not copies of) local functions.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id883574" href="#id883574" class="para">17</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id883056" href="#id883056" class="para">17</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> Local functions are often named
<code class="computeroutput"><span class="identifier">l</span></code> in the casual examples
of this documentation because the name of the author starts with the letter
"<code class="computeroutput"><span class="identifier">l</span></code>". <span class="inlinemediaobject"><img src="../../images/smiley.png" alt="smiley"></span>
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id885504" href="#id885504" class="para">18</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id883457" href="#id883457" class="para">18</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.id885968" href="#id885968" class="para">19</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id883921" href="#id883921" class="para">19</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> This is because within a nested
code block only global or static variables can be accessed while Boost.ScopeExit
variable <a href="http://lists.boost.org/Archives/boost/2006/11/113658.php" target="_top">binding
mechanism</a> requires to access local variables that hold the bound
variables.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id886406" href="#id886406" class="para">20</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id884359" href="#id884359" class="para">20</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/Grammar.html
==============================================================================
--- sandbox/local/libs/local/doc/html/boost_local/Grammar.html (original)
+++ sandbox/local/libs/local/doc/html/boost_local/Grammar.html 2011-02-27 12:35:43 EST (Sun, 27 Feb 2011)
@@ -132,7 +132,7 @@
<span class="special">(</span><span class="keyword">default</span><span class="special">)(</span><span class="bold"><strong>parameter-default</strong></span><span class="special">)</span> <span class="comment">// Default value for this optional parameter.
</span></pre>
<p>
- Binding variables in scope: <sup>[<a name="id891280" href="#ftn.id891280" class="footnote">21</a>]</sup> <sup>[<a name="id891585" href="#ftn.id891585" class="footnote">22</a>]</sup>
+ Binding variables in scope: <sup>[<a name="id889233" href="#ftn.id889233" class="footnote">21</a>]</sup> <sup>[<a name="id889538" href="#ftn.id889538" class="footnote">22</a>]</sup>
</p>
<pre class="programlisting"><span class="emphasis"><em>bindings:</em></span>
<span class="emphasis"><em>const-bindings</em></span> <span class="comment">// Only constant binding.
@@ -151,7 +151,7 @@
</span></pre>
<div class="footnotes">
<br><hr width="100" align="left">
-<div class="footnote"><p><sup>[<a id="ftn.id891280" href="#id891280" class="para">21</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id889233" href="#id889233" class="para">21</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> The alternative syntax <code class="computeroutput"><span class="special">(</span><span class="identifier">bind</span><span class="special">)((</span><span class="keyword">const</span><span class="special">&</span> <span class="identifier">x</span><span class="special">)...)</span></code>
would have been preferred because <code class="computeroutput"><span class="keyword">const</span></code>
appears before the reference as usual in C++ and because a single <code class="computeroutput"><span class="identifier">bind</span></code> sequence is used for both plain and
@@ -172,7 +172,7 @@
symbol <code class="computeroutput"><span class="special">&</span></code> never appears in
the back).
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id891585" href="#id891585" class="para">22</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id889538" href="#id889538" class="para">22</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> Binding is used within the function
parameter list because this syntax seemed natural given that the bound variables
are used by the function body as if they were function parameters (only their
Modified: sandbox/local/libs/local/doc/html/boost_local/Rationale.html
==============================================================================
--- sandbox/local/libs/local/doc/html/boost_local/Rationale.html (original)
+++ sandbox/local/libs/local/doc/html/boost_local/Rationale.html 2011-02-27 12:35:43 EST (Sun, 27 Feb 2011)
@@ -1018,7 +1018,7 @@
Default parameter values are not part of the type so it is not possible
to program a metafunction that counts the number of default parameter
values at compile-time but such information is also needed by the local
- functions in order to properly support default parameters. <sup>[<a name="id899668" href="#ftn.id899668" class="footnote">23</a>]</sup>
+ functions in order to properly support default parameters. <sup>[<a name="id897512" href="#ftn.id897512" class="footnote">23</a>]</sup>
</li>
</ol></div>
<p>
@@ -1037,7 +1037,7 @@
Note that the <code class="computeroutput"><span class="special">=</span></code> symbol needs
to be replaced with the alphanumeric keyword <code class="computeroutput"><span class="keyword">default</span></code>
because parenthesized syntax elements cannot start with a non alphanumeric
- symbol like <code class="computeroutput"><span class="special">=</span></code>. <sup>[<a name="id900067" href="#ftn.id900067" class="footnote">24</a>]</sup>
+ symbol like <code class="computeroutput"><span class="special">=</span></code>. <sup>[<a name="id897911" href="#ftn.id897911" class="footnote">24</a>]</sup>
</p>
<p>
For C99, some or all the parenthesis can be replaced by commas.
@@ -1215,7 +1215,7 @@
</div>
<div class="footnotes">
<br><hr width="100" align="left">
-<div class="footnote"><p><sup>[<a id="ftn.id899668" href="#id899668" class="para">23</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id897512" href="#id897512" class="para">23</a>] </sup>
Specifically, the number of default parameter value is needed at
compile-time to instantiate the proper <code class="computeroutput"><span class="identifier">function_ref</span><span class="special"><</span><span class="keyword">typename</span>
<span class="identifier">F</span><span class="special">,</span>
@@ -1224,7 +1224,7 @@
functor is needed to implement the trick that allows local functions
to be passed as template parameters (see http://lists.boost.org/Archives/boost/2010/09/170888.php).
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id900067" href="#id900067" class="para">24</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id897911" href="#id897911" class="para">24</a>] </sup>
This is because the parenthesized syntax needs to check if its token
matches a keyword like <code class="computeroutput"><span class="keyword">void</span></code>,
<code class="computeroutput"><span class="keyword">inline</span></code>, etc. This checking
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-02-27 12:35:43 EST (Sun, 27 Feb 2011)
@@ -812,27 +812,27 @@
<span class="identifier">T</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="identifier">T</span><span class="special">();</span>
<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="identifier">BOOST_LOCAL_FUNCTION_TPL</span><span class="special">(</span> <span class="comment">// Use `..._TPL()` macros in templates.
-</span> <span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">(</span><span class="identifier">add</span><span class="special">)(</span> <span class="special">(</span><span class="identifier">T</span><span class="special">)(</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="special">)((</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">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="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_END</span><span class="special">(</span><span class="identifier">add</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>
+ <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">add</span><span class="special">(</span><span class="identifier">x</span><span class="special">);</span>
- <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="identifier">T</span><span class="special">*</span> <span class="identifier">nums</span> <span class="special">=</span> <span class="keyword">new</span> <span class="identifier">T</span><span class="special">[</span><span class="identifier">size</span><span class="special">];</span>
- <span class="identifier">BOOST_LOCAL_EXIT_TPL</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="special">)((</span><span class="identifier">nums</span><span class="special">))</span> <span class="special">)</span> <span class="special">{</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="special">}</span> <span class="identifier">BOOST_LOCAL_EXIT_END</span>
-
- <span class="identifier">nums</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="special">=</span> <span class="identifier">y</span><span class="special">;</span> <span class="identifier">nums</span><span class="special">[</span><span class="number">1</span><span class="special">]</span> <span class="special">=</span> <span class="identifier">z</span><span class="special">;</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">nums</span><span class="special">,</span> <span class="identifier">nums</span> <span class="special">+</span> <span class="identifier">size</span><span class="special">,</span> <span class="identifier">add</span><span class="special">);</span>
-
- <span class="identifier">BOOST_LOCAL_BLOCK_TPL</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="identifier">factor</span><span class="special">)(&</span><span class="identifier">x</span><span class="special">)(&</span><span class="identifier">y</span><span class="special">)(&</span><span class="identifier">z</span><span class="special">))</span> <span class="special">)</span> <span class="special">{</span>
- <span class="identifier">assert</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="special">(</span><span class="identifier">x</span> <span class="special">+</span> <span class="identifier">y</span> <span class="special">+</span> <span class="identifier">z</span><span class="special">));</span>
- <span class="special">}</span> <span class="identifier">BOOST_LOCAL_BLOCK_END</span>
-
+<span class="comment">// size_t size = 2;
+</span><span class="comment">// T* nums = new T[size];
+</span><span class="comment">// BOOST_LOCAL_EXIT_TPL( (const bind& size) (bind nums) ) {
+</span><span class="comment">// if (size && nums) delete[] nums;
+</span><span class="comment">// } BOOST_LOCAL_EXIT_END
+</span>
+<span class="comment">// nums[0] = y; nums[1] = z;
+</span><span class="comment">// std::for_each(nums, nums + size, add);
+</span>
+<span class="comment">// BOOST_LOCAL_BLOCK_TPL( (const bind &sum) (const bind& factor)
+</span><span class="comment">// (const bind& x) (const bind& y) (const bind& z) ) {
+</span><span class="comment">// assert(sum == factor * (x + y + z));
+</span><span class="comment">// } BOOST_LOCAL_BLOCK_END
+</span>
<span class="keyword">return</span> <span class="identifier">sum</span><span class="special">;</span>
<span class="special">}</span>
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-02-27 12:35:43 EST (Sun, 27 Feb 2011)
@@ -389,7 +389,7 @@
</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: February 24, 2011 at 04:03:25 GMT</small></p></td>
+<td align="left"><p><small>Last revised: February 25, 2011 at 17:02:25 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
Modified: sandbox/local/libs/local/doc/html/reference.html
==============================================================================
--- sandbox/local/libs/local/doc/html/reference.html (original)
+++ sandbox/local/libs/local/doc/html/reference.html 2011-02-27 12:35:43 EST (Sun, 27 Feb 2011)
@@ -58,7 +58,7 @@
<pre class="synopsis">
<a class="link" href="BOOST_LOCAL_EXIT.html" title="Macro BOOST_LOCAL_EXIT">BOOST_LOCAL_EXIT</a>(...)
-<a class="link" href="BOOST_LOCAL_EXIT_TPL.html" title="Macro BOOST_LOCAL_EXIT_TPL">BOOST_LOCAL_EXIT_TPL</a>(binding_list)
+<a class="link" href="BOOST_LOCAL_EXIT_TPL.html" title="Macro BOOST_LOCAL_EXIT_TPL">BOOST_LOCAL_EXIT_TPL</a>(...)
<a class="link" href="BOOST_LOCAL_EXIT_END.html" title="Macro BOOST_LOCAL_EXIT_END">BOOST_LOCAL_EXIT_END</a></pre>
</div>
<div class="section">
Modified: sandbox/local/libs/local/doc/qbk/local.qbk
==============================================================================
--- sandbox/local/libs/local/doc/qbk/local.qbk (original)
+++ sandbox/local/libs/local/doc/qbk/local.qbk 2011-02-27 12:35:43 EST (Sun, 27 Feb 2011)
@@ -80,8 +80,6 @@
[import ../../example/factorial.cpp]
[import ../../example/doit.cpp]
[import ../../example/add_except.cpp]
-[import ../../example/renamed_print.cpp]
-[import ../../example/renamed_exit.cpp]
[import ../../example/add_optimizers.cpp]
The Boost Local library implements local functions, local blocks, and local exits for the C++ programming language.
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-02-27 12:35:43 EST (Sun, 27 Feb 2011)
@@ -26,19 +26,19 @@
} BOOST_LOCAL_FUNCTION_NAME(add)
add(x);
-// size_t size = 2;
-// T* nums = new T[size];
-// BOOST_LOCAL_EXIT_TPL( (const bind& size) (bind nums) ) {
-// if (size && nums) delete[] nums;
-// } BOOST_LOCAL_EXIT_END
-
-// nums[0] = y; nums[1] = z;
-// std::for_each(nums, nums + size, add);
-
-// BOOST_LOCAL_BLOCK_TPL( (const bind &sum) (const bind& factor)
-// (const bind& x) (const bind& y) (const bind& z) ) {
-// assert(sum == factor * (x + y + z));
-// } BOOST_LOCAL_BLOCK_END
+ size_t size = 2;
+ T* nums = new T[size];
+ BOOST_LOCAL_EXIT_TPL( (const bind& size) (bind nums) ) {
+ if (size && nums) delete[] nums;
+ } BOOST_LOCAL_EXIT_END
+
+ nums[0] = y; nums[1] = z;
+ std::for_each(nums, nums + size, add);
+
+ BOOST_LOCAL_BLOCK_TPL( (const bind &sum) (const bind& factor)
+ (const bind& x) (const bind& y) (const bind& z) ) {
+ assert(sum == factor * (x + y + z));
+ } BOOST_LOCAL_BLOCK_END
return sum;
}
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