Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r70952 - 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/qbk libs/local/example
From: lorcaminiti_at_[hidden]
Date: 2011-04-03 13:54:13


Author: lcaminiti
Date: 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
New Revision: 70952
URL: http://svn.boost.org/trac/boost/changeset/70952

Log:
Eliminated extra copies during parameter passing using Boost.CallTraits.
Benchmarking alternative methods.
Added:
   sandbox/local/libs/local/example/add_function_block_exit.cpp
      - copied, changed from r70637, /sandbox/local/libs/local/example/add.cpp
   sandbox/local/libs/local/example/add_function_block_exit_callouts.cpp
      - copied, changed from r70637, /sandbox/local/libs/local/example/add_callouts.cpp
   sandbox/local/libs/local/example/add_function_block_exit_va.cpp
      - copied, changed from r70637, /sandbox/local/libs/local/example/add_va.cpp
   sandbox/local/libs/local/example/add_using_boost_lambda.cpp
      - copied, changed from r70637, /sandbox/local/libs/local/example/add_boost_lambda.cpp
   sandbox/local/libs/local/example/add_using_boost_local.cpp
      - copied, changed from r70637, /sandbox/local/libs/local/example/add_boost_local.cpp
   sandbox/local/libs/local/example/add_using_boost_local_va.cpp
      - copied, changed from r70637, /sandbox/local/libs/local/example/add_boost_local_va.cpp
   sandbox/local/libs/local/example/add_using_boost_phoenix.cpp
      - copied, changed from r70637, /sandbox/local/libs/local/example/add_boost_phoenix.cpp
   sandbox/local/libs/local/example/add_using_cpp0x_lambda.cpp
      - copied, changed from r70637, /sandbox/local/libs/local/example/add_cpp0x_lambda.cpp
   sandbox/local/libs/local/example/add_using_local_functor.cpp
      - copied, changed from r70637, /sandbox/local/libs/local/example/add_local_class.cpp
Removed:
   sandbox/local/libs/local/example/add.cpp
   sandbox/local/libs/local/example/add_boost_lambda.cpp
   sandbox/local/libs/local/example/add_boost_local.cpp
   sandbox/local/libs/local/example/add_boost_local_va.cpp
   sandbox/local/libs/local/example/add_boost_phoenix.cpp
   sandbox/local/libs/local/example/add_callouts.cpp
   sandbox/local/libs/local/example/add_cpp0x_lambda.cpp
   sandbox/local/libs/local/example/add_local_class.cpp
   sandbox/local/libs/local/example/add_va.cpp
Text files modified:
   sandbox/local/boost/local/aux_/abstract_function.hpp | 10 +
   sandbox/local/boost/local/aux_/function.hpp | 4
   sandbox/local/boost/local/aux_/function_macros/code_/param.hpp | 5
   sandbox/local/libs/local/doc/html/boost_local/Alternatives.html | 317 +++++++++++++++++++++++++++++++++------
   sandbox/local/libs/local/doc/html/boost_local/Release_Notes.html | 9 +
   sandbox/local/libs/local/doc/html/index.html | 2
   sandbox/local/libs/local/doc/qbk/alternatives.qbk | 90 ++++++++--
   sandbox/local/libs/local/doc/qbk/introduction.qbk | 2
   sandbox/local/libs/local/doc/qbk/local.qbk | 19 +-
   sandbox/local/libs/local/doc/qbk/release_notes.qbk | 2
   sandbox/local/libs/local/example/Jamfile.jam | 15 +
   sandbox/local/libs/local/example/add_function_block_exit.cpp | 2
   sandbox/local/libs/local/example/add_function_block_exit_callouts.cpp | 2
   sandbox/local/libs/local/example/add_function_block_exit_va.cpp | 2
   sandbox/local/libs/local/example/add_using_boost_lambda.cpp | 12
   sandbox/local/libs/local/example/add_using_boost_local.cpp | 10
   sandbox/local/libs/local/example/add_using_boost_local_va.cpp | 10
   sandbox/local/libs/local/example/add_using_boost_phoenix.cpp | 22 +-
   sandbox/local/libs/local/example/add_using_cpp0x_lambda.cpp | 7
   sandbox/local/libs/local/example/add_using_local_functor.cpp | 23 +-
   20 files changed, 434 insertions(+), 131 deletions(-)

Modified: sandbox/local/boost/local/aux_/abstract_function.hpp
==============================================================================
--- sandbox/local/boost/local/aux_/abstract_function.hpp (original)
+++ sandbox/local/boost/local/aux_/abstract_function.hpp 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
@@ -10,6 +10,7 @@
 
 # include "file.hpp"
 # include "../config.hpp"
+# include <boost/call_traits.hpp>
 # include <boost/preprocessor/iteration/iterate.hpp>
 # include <boost/preprocessor/repetition/repeat.hpp>
 # include <boost/preprocessor/repetition/enum.hpp>
@@ -23,10 +24,14 @@
 
 #define BOOST_LOCAL_AUX_arg_typename(z, arg_n, unused) \
     typename BOOST_LOCAL_AUX_arg_type(z, arg_n, unused)
-
+
+#define BOOST_LOCAL_AUX_param_type(z, arg_n, unused) \
+ typename ::boost::call_traits<BOOST_LOCAL_AUX_arg_type(z, arg_n, unused) \
+ >::param_type
+
 #define BOOST_LOCAL_AUX_abstract_operator_call(z, defaults_n, arity) \
     virtual R operator()(BOOST_PP_ENUM_ ## z(BOOST_PP_SUB(arity, defaults_n), \
- BOOST_LOCAL_AUX_arg_type, ~)) = 0;
+ BOOST_LOCAL_AUX_param_type, ~)) = 0;
 
 #define BOOST_LOCAL_AUX_template_name(defaults_count) \
     BOOST_PP_CAT(BOOST_PP_CAT(functor_defaults, defaults_count), _base)
@@ -46,6 +51,7 @@
 
 # undef BOOST_LOCAL_AUX_arg_type
 # undef BOOST_LOCAL_AUX_arg_typename
+# undef BOOST_LOCAL_AUX_param_type
 # undef BOOST_LOCAL_AUX_abstract_operator_call
 # undef BOOST_LOCAL_AUX_template_name
 

Modified: sandbox/local/boost/local/aux_/function.hpp
==============================================================================
--- sandbox/local/boost/local/aux_/function.hpp (original)
+++ sandbox/local/boost/local/aux_/function.hpp 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
@@ -11,6 +11,7 @@
 # include "abstract_function.hpp"
 # include "file.hpp"
 # include "../config.hpp"
+# include <boost/call_traits.hpp>
 # include <boost/preprocessor/iteration/iterate.hpp>
 # include <boost/preprocessor/repetition/repeat.hpp>
 # include <boost/preprocessor/repetition/enum.hpp>
@@ -27,7 +28,8 @@
     BOOST_PP_CAT(a, arg_n)
 
 #define BOOST_LOCAL_AUX_arg(z, arg_n, unused) \
- BOOST_LOCAL_AUX_arg_type(z, arg_n, unused) \
+ typename ::boost::call_traits<BOOST_LOCAL_AUX_arg_type(z, arg_n, unused) \
+ >::param_type \
     BOOST_LOCAL_AUX_arg_name(z, arg_n, unused)
 
 #define BOOST_LOCAL_AUX_arg_typename(z, arg_n, unused) \

Modified: sandbox/local/boost/local/aux_/function_macros/code_/param.hpp
==============================================================================
--- sandbox/local/boost/local/aux_/function_macros/code_/param.hpp (original)
+++ sandbox/local/boost/local/aux_/function_macros/code_/param.hpp 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
@@ -10,6 +10,7 @@
 #include "../../symbol.hpp"
 #include "../../scope_exit/scope_exit.hpp" // Use this lib's ScopeExit impl.
 #include "../../type_traits/add_pointed_const.hpp"
+#include <boost/call_traits.hpp>
 #include <boost/detail/preprocessor/keyword/this.hpp>
 #include <boost/detail/preprocessor/keyword/auto.hpp>
 #include <boost/detail/preprocessor/keyword/register.hpp>
@@ -172,7 +173,9 @@
         r, typename_keyword, i, param) \
     BOOST_PP_COMMA_IF(i) \
     typename_keyword \
- BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_UNBIND_ARG_TYPE_(BOOST_PP_INC(i)) \
+ ::boost::call_traits< \
+ BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_UNBIND_ARG_TYPE_( \
+ BOOST_PP_INC(i))>::param_type \
     BOOST_LOCAL_AUX_FUNCTION_CODE_PARAM_UNBIND_ARG_NAME_(BOOST_PP_INC(i))
 
 #endif // #include guard

Modified: sandbox/local/libs/local/doc/html/boost_local/Alternatives.html
==============================================================================
--- sandbox/local/libs/local/doc/html/boost_local/Alternatives.html (original)
+++ sandbox/local/libs/local/doc/html/boost_local/Alternatives.html 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
@@ -50,6 +50,7 @@
 <col>
 <col>
 <col>
+<col>
 </colgroup>
 <thead><tr>
 <th>
@@ -59,18 +60,23 @@
               </th>
 <th>
                 <p>
- This Library
+ Boost.Local (this library)
+ </p>
+ </th>
+<th>
+ <p>
+ Local Functor
                 </p>
               </th>
 <th>
                 <p>
- Local Classes
+ Global Functor (not local)
                 </p>
               </th>
 <th>
                 <p>
                   <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++0x
- lambda</a>
+ lambda</a> (not ISO C++)
                 </p>
               </th>
 <th>
@@ -88,7 +94,7 @@
 <tr>
 <td>
                 <p>
- <span class="emphasis"><em>Program body using usual C++ syntax</em></span>
+ <span class="emphasis"><em>Can be defined locally</em></span>
                 </p>
               </td>
 <td>
@@ -103,11 +109,57 @@
               </td>
 <td>
                 <p>
+ No so this not an alternative implementation of local functions.
+ </p>
+ </td>
+<td>
+ <p>
                   Yes.
                 </p>
               </td>
 <td>
                 <p>
+ Yes.
+ </p>
+ </td>
+<td>
+ <p>
+ Yes.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <span class="emphasis"><em>Can be defined using regular C++ statements</em></span>
+ </p>
+ </td>
+<td>
+ <p>
+ Yes (also reporting compiler error messages usual for function
+ statements).
+ </p>
+ </td>
+<td>
+ <p>
+ Yes (also reporting compiler error messages usual for function
+ statements).
+ </p>
+ </td>
+<td>
+ <p>
+ Yes (also reporting compiler error messages usual for function
+ statements).
+ </p>
+ </td>
+<td>
+ <p>
+ Yes (also reporting compiler error messages usual for function
+ statements).
+ </p>
+ </td>
+<td>
+ <p>
                   No.
                 </p>
               </td>
@@ -120,6 +172,43 @@
 <tr>
 <td>
                 <p>
+ <span class="emphasis"><em>Can be defined within expressions</em></span>
+ </p>
+ </td>
+<td>
+ <p>
+ No, defined only within declarations.
+ </p>
+ </td>
+<td>
+ <p>
+ No, defined only within declarations.
+ </p>
+ </td>
+<td>
+ <p>
+ No, defined only within declarations.
+ </p>
+ </td>
+<td>
+ <p>
+ Yes.
+ </p>
+ </td>
+<td>
+ <p>
+ Yes.
+ </p>
+ </td>
+<td>
+ <p>
+ Yes.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
                   <span class="emphasis"><em>Can be passed as template parameter (e.g., to STL algorithms)</em></span>
                 </p>
               </td>
@@ -130,7 +219,13 @@
               </td>
 <td>
                 <p>
- No (see "local class" in [StroustupGlossary]).
+ No with ISO C++ standard (see "local class" in [StroustupGlossary]).
+ (Yes with C++0x standard and some compilers like MSVC.)
+ </p>
+ </td>
+<td>
+ <p>
+ No.
                 </p>
               </td>
 <td>
@@ -165,14 +260,21 @@
               </td>
 <td>
                 <p>
- No.
+ No, programmers must manually manage functor member variable and
+ specify their types.
+ </p>
+ </td>
+<td>
+ <p>
+ No, programmers must manually manage functor member variable and
+ specify their types.
                 </p>
               </td>
 <td>
                 <p>
                   Yes, plus there is short-hand syntax to bind all variables in scope
                   at once (by value or by reference). However, there is no bind by
- constant value nor by constant reference.
+ constant reference.
                 </p>
               </td>
 <td>
@@ -182,43 +284,108 @@
               </td>
 <td>
                 <p>
- Yes.
+ Yes, using <code class="computeroutput"><span class="identifier">let</span></code>
+ which also allows to bind by constant reference.
                 </p>
               </td>
 </tr>
 <tr>
 <td>
                 <p>
- <span class="emphasis"><em>Can be defined within expressions</em></span>
+ <span class="emphasis"><em>Compile-Time</em></span> <sup>[<a name="id944627" href="#ftn.id944627" class="footnote">a</a>]</sup>
                 </p>
               </td>
 <td>
                 <p>
- No, defined only within declarations.
+ 0 seconds
                 </p>
               </td>
 <td>
                 <p>
- No, defined only within declarations.
+ 0 seconds
                 </p>
               </td>
 <td>
                 <p>
- Yes.
+ 0 seconds
                 </p>
               </td>
 <td>
                 <p>
- Yes.
+ 0 seconds
                 </p>
               </td>
 <td>
                 <p>
- Yes.
+ 0 seconds
+ </p>
+ </td>
+<td>
+ <p>
+ 0 seconds
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <span class="emphasis"><em>Run-Time</em></span> <sup>[<a name="id944729" href="#ftn.id944729" class="footnote">b</a>]</sup>
+ </p>
+ </td>
+<td>
+ <p>
+ 0 seconds
+ </p>
+ </td>
+<td>
+ <p>
+ 0 seconds
+ </p>
+ </td>
+<td>
+ <p>
+ 0 seconds
+ </p>
+ </td>
+<td>
+ <p>
+ 0 seconds
+ </p>
+ </td>
+<td>
+ <p>
+ 0 seconds
+ </p>
+ </td>
+<td>
+ <p>
+ 0 seconds
                 </p>
               </td>
 </tr>
 </tbody>
+<tbody class="footnotes"><tr><td colspan="7">
+<div class="footnote"><p><sup>[<a id="ftn.id944627" href="#id944627" class="para">a</a>] </sup>
+ Compilation times have been measured in seconds using the Linux
+ command <code class="literal">$ time g++ -O3 -Wall -Wextra -I&lt;BOOST_DIR&gt;
+ &lt;CPP_FILE&gt;</code> for the examples listed below for
+ all the different approaches. The <code class="literal">real</code> time
+ is the overall time that took to execute the command. The actual
+ time values can change from execution to execution therefore
+ they have been measured 3 times and the time reported it the
+ one with the middle <code class="literal">real</code> time value. The time
+ values are machine dependent so they have no absolute meaning
+ but they can be used in this context to compare the performances
+ of the different approaches relative to each other (because all
+ these values were measured on the same system).
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.id944729" href="#id944729" class="para">b</a>] </sup>
+ run times have been measured in seconds using the Linux command
+ <code class="literal">$ time &lt;COMPILED_PROGRAM&gt;</code> for the compiled
+ examples listed below for all the different approaches. The same
+ statistical approach as for compilation time was followed.
+ </p></div>
+</td></tr></tbody>
 </table></div>
 <p>
         For example, using this library local functions:
@@ -259,15 +426,15 @@
 
     <span class="comment">// Unfortunately, cannot be defined at expression level.
 </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="comment">// Variable `factor` bound as constant.
+ <span class="comment">// Bind `sum` as reference and `factor` as constant reference.
 </span> <span class="identifier">bind</span><span class="special">&amp;</span> <span class="identifier">sum</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">bind</span><span class="special">&amp;</span> <span class="identifier">factor</span><span class="special">)</span> <span class="special">{</span>
- <span class="comment">// Body uses normal C++ syntax.
+ <span class="comment">// Body uses C++ statement syntax.
 </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">&lt;&lt;</span> <span class="string">"Summed: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">sum</span> <span class="special">&lt;&lt;</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>
- <span class="comment">// Local function `add` passed as template parameter.
-</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</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">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">add</span><span class="special">);</span> <span class="comment">// Passed as template parameter.
+</span>
     <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">sum</span> <span class="special">&lt;&lt;</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="number">0</span><span class="special">;</span>
 <span class="special">}</span>
@@ -293,15 +460,15 @@
 
     <span class="comment">// Unfortunately, cannot be defined at expression level.
 </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="comment">// Variable `factor` bound as constant.
+ <span class="comment">// Bind `sum` as ref and `factor` as const ref.
 </span> <span class="special">(</span><span class="identifier">bind</span><span class="special">&amp;</span> <span class="identifier">sum</span><span class="special">)</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">&amp;</span> <span class="identifier">factor</span><span class="special">)</span> <span class="special">)</span> <span class="special">{</span>
- <span class="comment">// Body uses normal C++ syntax.
+ <span class="comment">// Body uses C++ statement syntax.
 </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">&lt;&lt;</span> <span class="string">"Summed: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">sum</span> <span class="special">&lt;&lt;</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>
- <span class="comment">// Local function `add` passed as template parameter.
-</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</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">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">add</span><span class="special">);</span> <span class="comment">// Passed as template parameter.
+</span>
     <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">sum</span> <span class="special">&lt;&lt;</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="number">0</span><span class="special">;</span>
 <span class="special">}</span>
@@ -312,7 +479,7 @@
 </tr></tbody>
 </table></div>
 <p>
- Or using C++ member functions of local classes:
+ Or using C++ local functors:
       </p>
 <p>
         
@@ -328,22 +495,67 @@
     <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">v</span><span class="special">(</span><span class="number">3</span><span class="special">);</span>
     <span class="identifier">v</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="special">=</span> <span class="number">1.0</span><span class="special">;</span> <span class="identifier">v</span><span class="special">[</span><span class="number">1</span><span class="special">]</span> <span class="special">=</span> <span class="number">2.0</span><span class="special">;</span> <span class="identifier">v</span><span class="special">[</span><span class="number">2</span><span class="special">]</span> <span class="special">=</span> <span class="number">3.0</span><span class="special">;</span>
 
- <span class="keyword">struct</span> <span class="identifier">local</span> <span class="special">{</span>
- <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">add</span><span class="special">(</span><span class="keyword">double</span> <span class="identifier">num</span><span class="special">,</span>
- <span class="comment">// Unfortunately, cannot bind so repeat local variable types.
-</span> <span class="keyword">double</span><span class="special">&amp;</span> <span class="identifier">sum</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">int</span><span class="special">&amp;</span> <span class="identifier">factor</span><span class="special">)</span> <span class="special">{</span>
- <span class="comment">// Body uses normal C++ syntax.
+ <span class="keyword">struct</span> <span class="identifier">local_add</span> <span class="special">{</span> <span class="comment">// Unfortunately, boilerplate code to program the class.
+</span> <span class="identifier">local_add</span><span class="special">(</span><span class="keyword">double</span><span class="special">&amp;</span> <span class="identifier">_sum</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">_factor</span><span class="special">):</span> <span class="identifier">sum</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">_factor</span><span class="special">)</span> <span class="special">{}</span>
+
+ <span class="keyword">void</span> <span class="keyword">operator</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="comment">// Body uses C++ statement syntax.
 </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">&lt;&lt;</span> <span class="string">"Summed: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">sum</span> <span class="special">&lt;&lt;</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="special">};</span>
+
+ <span class="keyword">private</span><span class="special">:</span>
+ <span class="comment">// Unfortunately, cannot bind so repeat variable types.
+</span> <span class="keyword">double</span><span class="special">&amp;</span> <span class="identifier">sum</span><span class="special">;</span> <span class="comment">// Access `sum` by reference.
+</span> <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">factor</span><span class="special">;</span> <span class="comment">// Make `factor` constant.
+</span> <span class="special">}</span> <span class="identifier">add</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="comment">// Unfortunately, cannot pass as template parameter to `std::for_each`.
-</span> <span class="keyword">for</span> <span class="special">(</span><span class="identifier">size_t</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">size</span><span class="special">();</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="special">{</span>
- <span class="comment">// Unfortunately, explicitly pass variables `sum` and `factor`.
-</span> <span class="identifier">local</span><span class="special">::</span><span class="identifier">add</span><span class="special">(</span><span class="identifier">v</span><span class="special">[</span><span class="identifier">i</span><span class="special">],</span> <span class="identifier">sum</span><span class="special">,</span> <span class="identifier">factor</span><span class="special">);</span>
+</span> <span class="keyword">for</span> <span class="special">(</span><span class="identifier">size_t</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">size</span><span class="special">();</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">add</span><span class="special">(</span><span class="identifier">v</span><span class="special">[</span><span class="identifier">i</span><span class="special">]);</span>
+
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">sum</span> <span class="special">&lt;&lt;</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="number">0</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ Or using C++ global functors (but these do not allow to define the function
+ locally so they are not an alternative implementation of local functions):
+ </p>
+<p>
+
+</p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>
+<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">vector</span><span class="special">&gt;</span>
+<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">algorithm</span><span class="special">&gt;</span>
+
+<span class="comment">// Unfortunately, cannot be defined locally (so this is not an alternative
+</span><span class="comment">// implementation of local functions).
+</span><span class="keyword">struct</span> <span class="identifier">global_add</span> <span class="special">{</span> <span class="comment">// Unfortunately, boilerplate code to program the class.
+</span> <span class="identifier">global_add</span><span class="special">(</span><span class="keyword">double</span><span class="special">&amp;</span> <span class="identifier">_sum</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">_factor</span><span class="special">):</span> <span class="identifier">sum</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">_factor</span><span class="special">)</span> <span class="special">{}</span>
+
+ <span class="keyword">void</span> <span class="keyword">operator</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="comment">// Body uses C++ statement syntax.
+</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">&lt;&lt;</span> <span class="string">"Summed: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">sum</span> <span class="special">&lt;&lt;</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="keyword">private</span><span class="special">:</span>
+ <span class="comment">// Unfortunately, cannot bind so repeat variable types.
+</span> <span class="keyword">double</span><span class="special">&amp;</span> <span class="identifier">sum</span><span class="special">;</span> <span class="comment">// Access `sum` by reference.
+</span> <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">factor</span><span class="special">;</span> <span class="comment">// Make `factor` constant.
+</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">double</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">0.0</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">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">v</span><span class="special">(</span><span class="number">3</span><span class="special">);</span>
+ <span class="identifier">v</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="special">=</span> <span class="number">1.0</span><span class="special">;</span> <span class="identifier">v</span><span class="special">[</span><span class="number">1</span><span class="special">]</span> <span class="special">=</span> <span class="number">2.0</span><span class="special">;</span> <span class="identifier">v</span><span class="special">[</span><span class="number">2</span><span class="special">]</span> <span class="special">=</span> <span class="number">3.0</span><span class="special">;</span>
+
+ <span class="identifier">global_add</span> <span class="identifier">add</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">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">add</span><span class="special">);</span> <span class="comment">// Passed as template parameter.
+</span>
     <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">sum</span> <span class="special">&lt;&lt;</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="number">0</span><span class="special">;</span>
 <span class="special">}</span>
@@ -352,7 +564,7 @@
       </p>
 <p>
         Or using <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++0x
- lambda</a> functions:
+ lambda</a> functions (but not part of ISO C++ standard):
       </p>
 <p>
         
@@ -369,8 +581,9 @@
     <span class="identifier">v</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="special">=</span> <span class="number">1.0</span><span class="special">;</span> <span class="identifier">v</span><span class="special">[</span><span class="number">1</span><span class="special">]</span> <span class="special">=</span> <span class="number">2.0</span><span class="special">;</span> <span class="identifier">v</span><span class="special">[</span><span class="number">2</span><span class="special">]</span> <span class="special">=</span> <span class="number">3.0</span><span class="special">;</span>
 
     <span class="comment">// Passed as template parameter and also defined at expression level.
-</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="special">[&amp;</span><span class="identifier">sum</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">factor</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="comment">// Unfortunately, cannot make `factor` constant.
+</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="special">[&amp;</span><span class="identifier">sum</span><span class="special">,</span> <span class="identifier">factor</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="comment">// Unfortunately, cannot bind `factor` by constant reference (but only
+</span> <span class="comment">// by constant value requiring copy constructor and extra operation).
 </span> <span class="comment">// Body uses normal C++ syntax.
 </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">&lt;&lt;</span> <span class="string">"Summed: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">sum</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
@@ -395,6 +608,9 @@
 <span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">algorithm</span><span class="special">&gt;</span>
 
 <span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> <span class="special">{</span>
+ <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">lambda</span><span class="special">::</span><span class="identifier">_1</span><span class="special">;</span>
+ <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">lambda</span><span class="special">::</span><span class="identifier">var</span><span class="special">;</span>
+
     <span class="keyword">double</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">0.0</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>
 
@@ -404,10 +620,9 @@
     <span class="comment">// Passed as template parameter and also defined at expression level.
 </span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="special">(</span>
         <span class="comment">// Unfortunately, cannot make `factor` constant.
-</span> <span class="comment">// Unfortunately, body cannot use normal C++ syntax.
-</span> <span class="identifier">sum</span> <span class="special">+=</span> <span class="identifier">factor</span> <span class="special">*</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">lambda</span><span class="special">::</span><span class="identifier">_1</span><span class="special">,</span>
- <span class="identifier">boost</span><span class="special">::</span><span class="identifier">lambda</span><span class="special">::</span><span class="identifier">var</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="special">&lt;&lt;</span> <span class="string">"Summed: "</span> <span class="special">&lt;&lt;</span>
- <span class="identifier">boost</span><span class="special">::</span><span class="identifier">lambda</span><span class="special">::</span><span class="identifier">var</span><span class="special">(</span><span class="identifier">sum</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span>
+</span> <span class="comment">// Unfortunately, body cannot use C++ statement syntax.
+</span> <span class="identifier">sum</span> <span class="special">+=</span> <span class="identifier">factor</span> <span class="special">*</span> <span class="identifier">_1</span><span class="special">,</span>
+ <span class="identifier">var</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="special">&lt;&lt;</span> <span class="string">"Summed: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">var</span><span class="special">(</span><span class="identifier">sum</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span>
     <span class="special">));</span>
 
     <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">sum</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
@@ -422,14 +637,19 @@
 <p>
         
 </p>
-<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">spirit</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">qi</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
-<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">spirit</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">phoenix_core</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
-<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">spirit</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">phoenix_operator</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">spirit</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
 <span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>
 <span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">vector</span><span class="special">&gt;</span>
 <span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">algorithm</span><span class="special">&gt;</span>
 
 <span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> <span class="special">{</span>
+ <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">let</span><span class="special">;</span>
+ <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">local_names</span><span class="special">::</span><span class="identifier">_f</span><span class="special">;</span>
+ <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">cref</span><span class="special">;</span>
+ <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">ref</span><span class="special">;</span>
+ <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">arg_names</span><span class="special">::</span><span class="identifier">_1</span><span class="special">;</span>
+ <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">val</span><span class="special">;</span>
+
     <span class="keyword">double</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">0.0</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>
 
@@ -437,13 +657,12 @@
     <span class="identifier">v</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="special">=</span> <span class="number">1.0</span><span class="special">;</span> <span class="identifier">v</span><span class="special">[</span><span class="number">1</span><span class="special">]</span> <span class="special">=</span> <span class="number">2.0</span><span class="special">;</span> <span class="identifier">v</span><span class="special">[</span><span class="number">2</span><span class="special">]</span> <span class="special">=</span> <span class="number">3.0</span><span class="special">;</span>
 
     <span class="comment">// Passed as template parameter and also defined at expression level.
-</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="special">(</span>
- <span class="comment">// Unfortunately, cannot make `factor` constant.
-</span> <span class="comment">// Unfortunately, body cannot use normal C++ syntax.
-</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span><span class="identifier">sum</span><span class="special">)</span> <span class="special">+=</span> <span class="identifier">factor</span> <span class="special">*</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">qi</span><span class="special">::</span><span class="identifier">_1</span><span class="special">,</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">val</span><span class="special">(</span><span class="string">"Summed: "</span><span class="special">)</span> <span class="special">&lt;&lt;</span>
- <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">ref</span><span class="special">(</span><span class="identifier">sum</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span>
- <span class="special">));</span>
+</span> <span class="comment">// Bind `factor` by constant.
+</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">let</span><span class="special">(</span><span class="identifier">_f</span> <span class="special">=</span> <span class="identifier">cref</span><span class="special">(</span><span class="identifier">factor</span><span class="special">))[</span>
+ <span class="comment">// Unfortunately, body cannot use C++ statement syntax.
+</span> <span class="identifier">ref</span><span class="special">(</span><span class="identifier">sum</span><span class="special">)</span> <span class="special">+=</span> <span class="identifier">_f</span> <span class="special">*</span> <span class="identifier">_1</span><span class="special">,</span> <span class="comment">// Access `sum` by reference.
+</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">val</span><span class="special">(</span><span class="string">"Summed: "</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">ref</span><span class="special">(</span><span class="identifier">sum</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span>
+ <span class="special">]);</span>
 
     <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">sum</span> <span class="special">&lt;&lt;</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="number">0</span><span class="special">;</span>

Modified: sandbox/local/libs/local/doc/html/boost_local/Release_Notes.html
==============================================================================
--- sandbox/local/libs/local/doc/html/boost_local/Release_Notes.html (original)
+++ sandbox/local/libs/local/doc/html/boost_local/Release_Notes.html 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
@@ -81,6 +81,15 @@
 <span class="special">&gt;</span> <span class="identifier">C</span><span class="special">++</span><span class="number">03</span><span class="special">,</span> <span class="identifier">with</span> <span class="identifier">the</span> <span class="keyword">virtual</span> <span class="identifier">function</span> <span class="identifier">business</span> <span class="identifier">in</span> <span class="identifier">only</span> <span class="identifier">those</span> <span class="identifier">compilers</span><span class="special">/</span><span class="identifier">modes</span>
 <span class="special">&gt;</span> <span class="identifier">where</span> <span class="identifier">it</span> <span class="identifier">is</span> <span class="identifier">necessary</span><span class="special">.</span>
 </pre>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
+ Shall <code class="computeroutput"><span class="identifier">this_</span></code> be named
+ <code class="computeroutput"><span class="identifier">_this</span></code> instead? Ask Boosters
+ if there is some guideline for consistency. Maybe Boost uses <code class="computeroutput"><span class="special">...</span><span class="identifier">_</span></code>
+ is for statements (like <code class="computeroutput"><span class="identifier">if_</span></code>)
+ and <code class="computeroutput"><span class="identifier">_</span><span class="special">...</span></code>
+ for variables (like <code class="computeroutput"><span class="identifier">_1</span></code>)...
+ if that is the case then I should use <code class="computeroutput"><span class="identifier">_this</span></code>.
+ </li></ul></div>
 </div>
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>

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-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
@@ -416,7 +416,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: March 27, 2011 at 14:50:23 GMT</small></p></td>
+<td align="left"><p><small>Last revised: March 30, 2011 at 18:18:10 GMT</small></p></td>
 <td align="right"><div class="copyright-footer"></div></td>
 </tr></table>
 <hr>

Modified: sandbox/local/libs/local/doc/qbk/alternatives.qbk
==============================================================================
--- sandbox/local/libs/local/doc/qbk/alternatives.qbk (original)
+++ sandbox/local/libs/local/doc/qbk/alternatives.qbk 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
@@ -15,24 +15,45 @@
 [table
 [
     [ Local Function Feature ]
- [ This Library ]
- [ Local Classes ]
- [ __CPP0x_lambda__ ]
+ [ Boost.Local (this library) ]
+ [ Local Functor ]
+ [ Global Functor (not local) ]
+ [ __CPP0x_lambda__ (not ISO C++) ]
     [ __Boost_Lambda__ ]
     [ __Boost_Phoenix__ ]
 ]
 [
- [ ['Program body using usual C++ syntax] ]
+ [ ['Can be defined locally] ]
     [ Yes. ]
     [ Yes. ]
+ [ No so this not an alternative implementation of local functions. ]
     [ Yes. ]
+ [ Yes. ]
+ [ Yes. ]
+]
+[
+ [ ['Can be defined using regular C++ statements] ]
+ [ Yes (also reporting compiler error messages usual for function statements). ]
+ [ Yes (also reporting compiler error messages usual for function statements). ]
+ [ Yes (also reporting compiler error messages usual for function statements). ]
+ [ Yes (also reporting compiler error messages usual for function statements). ]
     [ No. ]
     [ No. ]
 ]
 [
+ [ ['Can be defined within expressions] ]
+ [ No, defined only within declarations. ]
+ [ No, defined only within declarations. ]
+ [ No, defined only within declarations. ]
+ [ Yes. ]
+ [ Yes. ]
+ [ Yes. ]
+]
+[
     [ ['Can be passed as template parameter (e.g., to STL algorithms)] ]
     [ Yes. ]
- [ No (see "local class" in __StroustrupGlossary__). ]
+ [ No with ISO C++ standard (see "local class" in __StroustrupGlossary__). (Yes with C++0x standard and some compilers like MSVC.) ]
+ [ No. ]
     [ Yes. ]
     [ Yes. ]
     [ Yes. ]
@@ -41,19 +62,42 @@
     [ ['Bind variables in scope] ]
     [ Yes, bind by value, constant value, reference, and constant reference (also bind the object `this`).
 However, the names of the bound variables must be repeated one by one.]
- [ No. ]
+ [ No, programmers must manually manage functor member variable and specify their types. ]
+ [ No, programmers must manually manage functor member variable and specify their types. ]
     [ Yes, plus there is short-hand syntax to bind all variables in scope at once (by value or by reference).
-However, there is no bind by constant value nor by constant reference. ]
+However, there is no bind by constant reference. ]
     [ No. ]
- [ Yes. ]
+ [ Yes, using `let` which also allows to bind by constant reference. ]
 ]
 [
- [ ['Can be defined within expressions] ]
- [ No, defined only within declarations. ]
- [ No, defined only within declarations. ]
- [ Yes. ]
- [ Yes. ]
- [ Yes. ]
+ [ ['Compile-Time]
+[footnote
+Compilation times have been measured in seconds using the Linux command [^$ time g++ -O3 -Wall -Wextra -I<BOOST_DIR> <CPP_FILE>] for the examples listed below for all the different approaches.
+The [^real] time is the overall time that took to execute the command.
+The actual time values can change from execution to execution therefore they have been measured 3 times and the time reported it the one with the middle [^real] time value.
+The time values are machine dependent so they have no absolute meaning but they can be used in this context to compare the performances of the different approaches relative to each other (because all these values were measured on the same system).
+]
+ ]
+ [ 0 seconds ]
+ [ 0 seconds ]
+ [ 0 seconds ]
+ [ 0 seconds ]
+ [ 0 seconds ]
+ [ 0 seconds ]
+]
+[
+ [ ['Run-Time]
+[footnote
+run times have been measured in seconds using the Linux command [^$ time <COMPILED_PROGRAM>] for the compiled examples listed below for all the different approaches.
+The same statistical approach as for compilation time was followed.
+]
+ ]
+ [ 0 seconds ]
+ [ 0 seconds ]
+ [ 0 seconds ]
+ [ 0 seconds ]
+ [ 0 seconds ]
+ [ 0 seconds ]
 ]
 ]
 
@@ -61,24 +105,28 @@
 
 [table
 [ [__Variadic_Macro_Syntax__] [__Sequencing_Macro_Syntax__] ]
-[ [ [add_boost_local_va_cpp] ] [ [add_boost_local_cpp] ] ]
+[ [ [add_using_boost_local_va_cpp] ] [ [add_using_boost_local_cpp] ] ]
 ]
 
-Or using C++ member functions of local classes:
+Or using C++ local functors:
+
+[add_using_local_functor_cpp]
+
+Or using C++ global functors (but these do not allow to define the function locally so they are not an alternative implementation of local functions):
 
-[add_local_class_cpp]
+[add_using_global_functor_cpp]
 
-Or using __CPP0x_lambda__ functions:
+Or using __CPP0x_lambda__ functions (but not part of ISO C++ standard):
 
-[add_cpp0x_lambda_cpp]
+[add_using_cpp0x_lambda_cpp]
 
 Or using __Boost_Lambda__ functions:
 
-[add_boost_lambda_cpp]
+[add_using_boost_lambda_cpp]
 
 Or using __Boost_Phoenix__:
 
-[add_boost_phoenix_cpp]
+[add_using_boost_phoenix_cpp]
 
 [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-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
@@ -46,7 +46,7 @@
 
 [table
 [ [Notes] [__Variadic_Macro_Syntax__] [__Sequencing_Macro_Syntax__] ]
-[ [ [add_callouts_cpp] ] [ [add_va_cpp] ] [ [add_cpp] ] ]
+[ [ [add_function_block_exit_callouts_cpp] ] [ [add_function_block_exit_va_cpp] ] [ [add_function_block_exit_cpp] ] ]
 ]
 
 Notes:

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-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
@@ -74,9 +74,9 @@
 [def __Sequencing_Macro_Syntax__ Sequencing Macro Syntax (all C++ compilers)]
 [def __Empty_Macro_Syntax__ Empty Macro Syntax (C99 and other modern compilers)]
 
-[import ../../example/add_callouts.cpp]
-[import ../../example/add.cpp]
-[import ../../example/add_va.cpp]
+[import ../../example/add_function_block_exit_callouts.cpp]
+[import ../../example/add_function_block_exit.cpp]
+[import ../../example/add_function_block_exit_va.cpp]
 [import ../../example/add_x_y.cpp]
 [import ../../example/add_x_y_va.cpp]
 [import ../../example/ten.cpp]
@@ -134,12 +134,13 @@
 [import ../../example/factorial_impl.cpp]
 [import ../../example/add_block_impl.cpp]
 [import ../../example/add_exit_impl.cpp]
-[import ../../example/add_boost_local.cpp]
-[import ../../example/add_boost_local_va.cpp]
-[import ../../example/add_local_class.cpp]
-[import ../../example/add_cpp0x_lambda.cpp]
-[import ../../example/add_boost_lambda.cpp]
-[import ../../example/add_boost_phoenix.cpp]
+[import ../../example/add_using_boost_local.cpp]
+[import ../../example/add_using_boost_local_va.cpp]
+[import ../../example/add_using_local_functor.cpp]
+[import ../../example/add_using_global_functor.cpp]
+[import ../../example/add_using_cpp0x_lambda.cpp]
+[import ../../example/add_using_boost_lambda.cpp]
+[import ../../example/add_using_boost_phoenix.cpp]
 
 The Boost Local library implements local functions, local blocks, and local exits for the C++ programming language.
 

Modified: sandbox/local/libs/local/doc/qbk/release_notes.qbk
==============================================================================
--- sandbox/local/libs/local/doc/qbk/release_notes.qbk (original)
+++ sandbox/local/libs/local/doc/qbk/release_notes.qbk 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
@@ -40,6 +40,8 @@
> C++03, with the virtual function business in only those compilers/modes
> where it is necessary.
 
+* Shall `this_` be named `_this` instead? Ask Boosters if there is some guideline for consistency. Maybe Boost uses `..._` is for statements (like `if_`) and `_...` for variables (like `_1`)... if that is the case then I should use `_this`.
+
 [endsect]
 
 [endsect]

Modified: sandbox/local/libs/local/example/Jamfile.jam
==============================================================================
--- sandbox/local/libs/local/example/Jamfile.jam (original)
+++ sandbox/local/libs/local/example/Jamfile.jam 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
@@ -104,10 +104,13 @@
 exe world_exit : world_exit.cpp ;
 exe world_exit_va : world_exit_va.cpp ;
 
-exe add_boost_local : add_boost_local.cpp ;
-exe add_boost_local_va : add_boost_local_va.cpp ;
-exe add_local_class : add_local_class.cpp ;
-exe add_cpp0x_lambda : add_cpp0x_lambda.cpp ;
-exe add_boost_lambda : add_boost_lambda.cpp ;
-exe add_boost_phoenix : add_boost_phoenix.cpp ;
+exe add_using_boost_local : add_using_boost_local.cpp ;
+exe add_using_boost_local_va : add_usign_boost_local_va.cpp ;
+exe add_using_local_functor : add_using_local_functor.cpp ;
+exe add_using_global_functor : add_using_global_functor.cpp ;
+exe add_using_cpp0x_lambda : add_using_cpp0x_lambda.cpp ;
+exe add_using_boost_lambda : add_using_boost_lambda.cpp ;
+exe add_using_boost_phoenix : add_using_boost_phoenix.cpp ;
+
+exe l10 : l10.cpp ;
 

Deleted: sandbox/local/libs/local/example/add.cpp
==============================================================================
--- sandbox/local/libs/local/example/add.cpp 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
+++ (empty file)
@@ -1,45 +0,0 @@
-
-// Copyright (C) 2009-2011 Lorenzo Caminiti
-// 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).
-
-//[ add_cpp
-#include <boost/local/function.hpp>
-#include <boost/local/block.hpp>
-#include <boost/local/exit.hpp>
-
-#include <algorithm>
-#include <iostream>
-#include <cassert>
-
-int main() {
- double sum = 0.0;
- int factor = 10;
-
- void BOOST_LOCAL_FUNCTION_PARAMS( (double num)
- (const bind factor) (bind& sum) ) {
- sum += factor * num;
- std::cout << "Summed: " << sum << std::endl;
- } BOOST_LOCAL_FUNCTION_NAME(add)
- add(100.0);
-
- size_t size = 2;
- double* nums = new double[size];
- BOOST_LOCAL_EXIT( (const bind& size) (bind nums) ) {
- if (size && nums) delete[] nums;
- std::cout << "Freed array: " << nums << std::endl;
- } BOOST_LOCAL_EXIT_END
-
- nums[0] = 90.5; nums[1] = 7.0;
- std::for_each(nums, nums + size, add); // `add` as template parameter
-
- BOOST_LOCAL_BLOCK( (const bind& sum) ) {
- assert(sum == 1975.0); // so far `sum` is 10*100+10*90.5+10*7=1975
- std::cout << "Asserted summation: " << sum << std::endl;
- } BOOST_LOCAL_BLOCK_END
-
- return 0;
-}
-//]
-

Deleted: sandbox/local/libs/local/example/add_boost_lambda.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_boost_lambda.cpp 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
+++ (empty file)
@@ -1,33 +0,0 @@
-
-// Copyright (C) 2009-2011 Lorenzo Caminiti
-// 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).
-
-//[ add_boost_lambda_cpp
-#include <boost/lambda/lambda.hpp>
-#include <iostream>
-#include <vector>
-#include <algorithm>
-
-int main() {
- double sum = 0.0;
- int factor = 10;
-
- std::vector<double> v(3);
- v[0] = 1.0; v[1] = 2.0; v[2] = 3.0;
-
- // Passed as template parameter and also defined at expression level.
- std::for_each(v.begin(), v.end(), (
- // Unfortunately, cannot make `factor` constant.
- // Unfortunately, body cannot use normal C++ syntax.
- sum += factor * boost::lambda::_1,
- boost::lambda::var(std::cout) << "Summed: " <<
- boost::lambda::var(sum) << "\n"
- ));
-
- std::cout << sum << std::endl;
- return 0;
-}
-//]
-

Deleted: sandbox/local/libs/local/example/add_boost_local.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_boost_local.cpp 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
+++ (empty file)
@@ -1,35 +0,0 @@
-
-// Copyright (C) 2009-2011 Lorenzo Caminiti
-// 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).
-
-//[ add_boost_local_cpp
-#include <boost/local/function.hpp>
-#include <iostream>
-#include <vector>
-#include <algorithm>
-
-int main() {
- double sum = 0.0;
- int factor = 10;
-
- std::vector<double> v(3);
- v[0] = 1.0; v[1] = 2.0; v[2] = 3.0;
-
- // Unfortunately, cannot be defined at expression level.
- void BOOST_LOCAL_FUNCTION_PARAMS( (double num)
- // Variable `factor` bound as constant.
- (bind& sum) (const bind& factor) ) {
- // Body uses normal C++ syntax.
- sum += factor * num;
- std::cout << "Summed: " << sum << std::endl;
- } BOOST_LOCAL_FUNCTION_NAME(add)
- // Local function `add` passed as template parameter.
- std::for_each(v.begin(), v.end(), add);
-
- std::cout << sum << std::endl;
- return 0;
-}
-//]
-

Deleted: sandbox/local/libs/local/example/add_boost_local_va.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_boost_local_va.cpp 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
+++ (empty file)
@@ -1,46 +0,0 @@
-
-// Copyright (C) 2009-2011 Lorenzo Caminiti
-// 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).
-
-#include <boost/config.hpp>
-#if defined(BOOST_NO_VARIADIC_MACROS) || defined(BOOST_LOCAL_CONFIG_COMPLIANT)
-#include <iostream>
-int main() {
- std::cerr << "Error: This program requires variadic macros" << std::endl;
- return 0;
-}
-#else
-
-//[ add_boost_local_va_cpp
-#include <boost/local/function.hpp>
-#include <iostream>
-#include <vector>
-#include <algorithm>
-
-int main() {
- double sum = 0.0;
- int factor = 10;
-
- std::vector<double> v(3);
- v[0] = 1.0; v[1] = 2.0; v[2] = 3.0;
-
- // Unfortunately, cannot be defined at expression level.
- void BOOST_LOCAL_FUNCTION_PARAMS(double num,
- // Variable `factor` bound as constant.
- bind& sum, const bind& factor) {
- // Body uses normal C++ syntax.
- sum += factor * num;
- std::cout << "Summed: " << sum << std::endl;
- } BOOST_LOCAL_FUNCTION_NAME(add)
- // Local function `add` passed as template parameter.
- std::for_each(v.begin(), v.end(), add);
-
- std::cout << sum << std::endl;
- return 0;
-}
-//]
-
-#endif
-

Deleted: sandbox/local/libs/local/example/add_boost_phoenix.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_boost_phoenix.cpp 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
+++ (empty file)
@@ -1,33 +0,0 @@
-
-// Copyright (C) 2009-2011 Lorenzo Caminiti
-// 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).
-
-//[ add_boost_phoenix_cpp
-#include <boost/spirit/include/phoenix.hpp>
-#include <iostream>
-#include <vector>
-#include <algorithm>
-
-int main() {
- double sum = 0.0;
- int factor = 10;
-
- std::vector<double> v(3);
- v[0] = 1.0; v[1] = 2.0; v[2] = 3.0;
-
- // Passed as template parameter and also defined at expression level.
- std::for_each(v.begin(), v.end(), (
- // Unfortunately, cannot make `factor` constant.
- // Unfortunately, body cannot use normal C++ syntax.
- boost::phoenix::ref(sum) += factor * boost::phoenix::arg_names::_1,
- std::cout << boost::phoenix::val("Summed: ") <<
- boost::phoenix::ref(sum) << "\n"
- ));
-
- std::cout << sum << std::endl;
- return 0;
-}
-//]
-

Deleted: sandbox/local/libs/local/example/add_callouts.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_callouts.cpp 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
+++ (empty file)
@@ -1,44 +0,0 @@
-
-// Copyright (C) 2009-2011 Lorenzo Caminiti
-// 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).
-
-//[add_callouts_cpp
- 1.
-
-
-
-
-
-
-
-
-
-
-
- 2.
- 3.
- 4.
-
- 5.
- 6.
-
-
-
- 7.
- 8.
-
- 9.
-
-
-10.
-
-11.
-12.
-
-13.
-
-
-
-//]

Deleted: sandbox/local/libs/local/example/add_cpp0x_lambda.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_cpp0x_lambda.cpp 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
+++ (empty file)
@@ -1,42 +0,0 @@
-
-// Copyright (C) 2009-2011 Lorenzo Caminiti
-// 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).
-
-#include <boost/config.hpp>
-#ifdef BOOST_NO_LAMBDAS
-#include <iostream>
-int main() {
- std::cerr << "Error: This program requires C++0x lambdas" << std::endl;
- return 0;
-}
-#else
-
-//[ add_cpp0x_lambda_cpp
-#include <iostream>
-#include <vector>
-#include <algorithm>
-
-int main() {
- double sum = 0.0;
- int factor = 10;
-
- std::vector<double> v(3);
- v[0] = 1.0; v[1] = 2.0; v[2] = 3.0;
-
- // Passed as template parameter and also defined at expression level.
- std::for_each(v.begin(), v.end(), [&sum, &factor](double num) {
- // Unfortunately, cannot make `factor` constant.
- // Body uses normal C++ syntax.
- sum += factor * num;
- std::cout << "Summed: " << sum << std::endl;
- });
-
- std::cout << sum << std::endl;
- return 0;
-}
-//]
-
-#endif
-

Copied: sandbox/local/libs/local/example/add_function_block_exit.cpp (from r70637, /sandbox/local/libs/local/example/add.cpp)
==============================================================================
--- /sandbox/local/libs/local/example/add.cpp (original)
+++ sandbox/local/libs/local/example/add_function_block_exit.cpp 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
@@ -4,7 +4,7 @@
 // License, Version 1.0 (see accompanying file LICENSE_1_0.txt or a
 // copy at http://www.boost.org/LICENSE_1_0.txt).
 
-//[ add_cpp
+//[ add_function_block_exit_cpp
 #include <boost/local/function.hpp>
 #include <boost/local/block.hpp>
 #include <boost/local/exit.hpp>

Copied: sandbox/local/libs/local/example/add_function_block_exit_callouts.cpp (from r70637, /sandbox/local/libs/local/example/add_callouts.cpp)
==============================================================================
--- /sandbox/local/libs/local/example/add_callouts.cpp (original)
+++ sandbox/local/libs/local/example/add_function_block_exit_callouts.cpp 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
@@ -4,7 +4,7 @@
 // License, Version 1.0 (see accompanying file LICENSE_1_0.txt or a
 // copy at http://www.boost.org/LICENSE_1_0.txt).
 
-//[add_callouts_cpp
+//[add_function_block_exit_callouts_cpp
  1.
  
  

Copied: sandbox/local/libs/local/example/add_function_block_exit_va.cpp (from r70637, /sandbox/local/libs/local/example/add_va.cpp)
==============================================================================
--- /sandbox/local/libs/local/example/add_va.cpp (original)
+++ sandbox/local/libs/local/example/add_function_block_exit_va.cpp 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
@@ -13,7 +13,7 @@
 }
 #else
 
-//[ add_va_cpp
+//[ add_function_block_exit_va_cpp
 #include <boost/local/function.hpp>
 #include <boost/local/block.hpp>
 #include <boost/local/exit.hpp>

Deleted: sandbox/local/libs/local/example/add_local_class.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_local_class.cpp 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
+++ (empty file)
@@ -1,39 +0,0 @@
-
-// Copyright (C) 2009-2011 Lorenzo Caminiti
-// 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).
-
-//[ add_local_class_cpp
-#include <iostream>
-#include <vector>
-#include <algorithm>
-
-int main() {
- double sum = 0.0;
- int factor = 10;
-
- std::vector<double> v(3);
- v[0] = 1.0; v[1] = 2.0; v[2] = 3.0;
-
- struct local {
- static void add(double num,
- // Unfortunately, cannot bind so repeat local variable types.
- double& sum, const int& factor) {
- // Body uses normal C++ syntax.
- sum += factor * num;
- std::cout << "Summed: " << sum << std::endl;
- }
- };
-
- // Unfortunately, cannot pass as template parameter to `std::for_each`.
- for (size_t i = 0; i < v.size(); ++i) {
- // Unfortunately, explicitly pass variables `sum` and `factor`.
- local::add(v[i], sum, factor);
- }
-
- std::cout << sum << std::endl;
- return 0;
-}
-//]
-

Copied: sandbox/local/libs/local/example/add_using_boost_lambda.cpp (from r70637, /sandbox/local/libs/local/example/add_boost_lambda.cpp)
==============================================================================
--- /sandbox/local/libs/local/example/add_boost_lambda.cpp (original)
+++ sandbox/local/libs/local/example/add_using_boost_lambda.cpp 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
@@ -4,13 +4,16 @@
 // License, Version 1.0 (see accompanying file LICENSE_1_0.txt or a
 // copy at http://www.boost.org/LICENSE_1_0.txt).
 
-//[ add_boost_lambda_cpp
+//[ add_using_boost_lambda_cpp
 #include <boost/lambda/lambda.hpp>
 #include <iostream>
 #include <vector>
 #include <algorithm>
 
 int main() {
+ using boost::lambda::_1;
+ using boost::lambda::var;
+
     double sum = 0.0;
     int factor = 10;
 
@@ -20,10 +23,9 @@
     // Passed as template parameter and also defined at expression level.
     std::for_each(v.begin(), v.end(), (
         // Unfortunately, cannot make `factor` constant.
- // Unfortunately, body cannot use normal C++ syntax.
- sum += factor * boost::lambda::_1,
- boost::lambda::var(std::cout) << "Summed: " <<
- boost::lambda::var(sum) << "\n"
+ // Unfortunately, body cannot use C++ statement syntax.
+ sum += factor * _1,
+ var(std::cout) << "Summed: " << var(sum) << "\n"
     ));
 
     std::cout << sum << std::endl;

Copied: sandbox/local/libs/local/example/add_using_boost_local.cpp (from r70637, /sandbox/local/libs/local/example/add_boost_local.cpp)
==============================================================================
--- /sandbox/local/libs/local/example/add_boost_local.cpp (original)
+++ sandbox/local/libs/local/example/add_using_boost_local.cpp 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
@@ -4,7 +4,7 @@
 // License, Version 1.0 (see accompanying file LICENSE_1_0.txt or a
 // copy at http://www.boost.org/LICENSE_1_0.txt).
 
-//[ add_boost_local_cpp
+//[ add_using_boost_local_cpp
 #include <boost/local/function.hpp>
 #include <iostream>
 #include <vector>
@@ -19,14 +19,14 @@
 
     // Unfortunately, cannot be defined at expression level.
     void BOOST_LOCAL_FUNCTION_PARAMS( (double num)
- // Variable `factor` bound as constant.
+ // Bind `sum` as ref and `factor` as const ref.
             (bind& sum) (const bind& factor) ) {
- // Body uses normal C++ syntax.
+ // Body uses C++ statement syntax.
         sum += factor * num;
         std::cout << "Summed: " << sum << std::endl;
     } BOOST_LOCAL_FUNCTION_NAME(add)
- // Local function `add` passed as template parameter.
- std::for_each(v.begin(), v.end(), add);
+
+ std::for_each(v.begin(), v.end(), add); // Passed as template parameter.
 
     std::cout << sum << std::endl;
     return 0;

Copied: sandbox/local/libs/local/example/add_using_boost_local_va.cpp (from r70637, /sandbox/local/libs/local/example/add_boost_local_va.cpp)
==============================================================================
--- /sandbox/local/libs/local/example/add_boost_local_va.cpp (original)
+++ sandbox/local/libs/local/example/add_using_boost_local_va.cpp 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
@@ -13,7 +13,7 @@
 }
 #else
 
-//[ add_boost_local_va_cpp
+//[ add_using_boost_local_va_cpp
 #include <boost/local/function.hpp>
 #include <iostream>
 #include <vector>
@@ -28,14 +28,14 @@
 
     // Unfortunately, cannot be defined at expression level.
     void BOOST_LOCAL_FUNCTION_PARAMS(double num,
- // Variable `factor` bound as constant.
+ // Bind `sum` as reference and `factor` as constant reference.
             bind& sum, const bind& factor) {
- // Body uses normal C++ syntax.
+ // Body uses C++ statement syntax.
         sum += factor * num;
         std::cout << "Summed: " << sum << std::endl;
     } BOOST_LOCAL_FUNCTION_NAME(add)
- // Local function `add` passed as template parameter.
- std::for_each(v.begin(), v.end(), add);
+
+ std::for_each(v.begin(), v.end(), add); // Passed as template parameter.
 
     std::cout << sum << std::endl;
     return 0;

Copied: sandbox/local/libs/local/example/add_using_boost_phoenix.cpp (from r70637, /sandbox/local/libs/local/example/add_boost_phoenix.cpp)
==============================================================================
--- /sandbox/local/libs/local/example/add_boost_phoenix.cpp (original)
+++ sandbox/local/libs/local/example/add_using_boost_phoenix.cpp 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
@@ -4,13 +4,20 @@
 // License, Version 1.0 (see accompanying file LICENSE_1_0.txt or a
 // copy at http://www.boost.org/LICENSE_1_0.txt).
 
-//[ add_boost_phoenix_cpp
+//[ add_using_boost_phoenix_cpp
 #include <boost/spirit/include/phoenix.hpp>
 #include <iostream>
 #include <vector>
 #include <algorithm>
 
 int main() {
+ using boost::phoenix::let;
+ using boost::phoenix::local_names::_f;
+ using boost::phoenix::cref;
+ using boost::phoenix::ref;
+ using boost::phoenix::arg_names::_1;
+ using boost::phoenix::val;
+
     double sum = 0.0;
     int factor = 10;
 
@@ -18,13 +25,12 @@
     v[0] = 1.0; v[1] = 2.0; v[2] = 3.0;
 
     // Passed as template parameter and also defined at expression level.
- std::for_each(v.begin(), v.end(), (
- // Unfortunately, cannot make `factor` constant.
- // Unfortunately, body cannot use normal C++ syntax.
- boost::phoenix::ref(sum) += factor * boost::phoenix::arg_names::_1,
- std::cout << boost::phoenix::val("Summed: ") <<
- boost::phoenix::ref(sum) << "\n"
- ));
+ // Bind `factor` by constant.
+ std::for_each(v.begin(), v.end(), let(_f = cref(factor))[
+ // Unfortunately, body cannot use C++ statement syntax.
+ ref(sum) += _f * _1, // Access `sum` by reference.
+ std::cout << val("Summed: ") << ref(sum) << "\n"
+ ]);
 
     std::cout << sum << std::endl;
     return 0;

Copied: sandbox/local/libs/local/example/add_using_cpp0x_lambda.cpp (from r70637, /sandbox/local/libs/local/example/add_cpp0x_lambda.cpp)
==============================================================================
--- /sandbox/local/libs/local/example/add_cpp0x_lambda.cpp (original)
+++ sandbox/local/libs/local/example/add_using_cpp0x_lambda.cpp 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
@@ -13,7 +13,7 @@
 }
 #else
 
-//[ add_cpp0x_lambda_cpp
+//[ add_using_cpp0x_lambda_cpp
 #include <iostream>
 #include <vector>
 #include <algorithm>
@@ -26,8 +26,9 @@
     v[0] = 1.0; v[1] = 2.0; v[2] = 3.0;
 
     // Passed as template parameter and also defined at expression level.
- std::for_each(v.begin(), v.end(), [&sum, &factor](double num) {
- // Unfortunately, cannot make `factor` constant.
+ std::for_each(v.begin(), v.end(), [&sum, factor](double num) {
+ // Unfortunately, cannot bind `factor` by constant reference (but only
+ // by constant value requiring copy constructor and extra operation).
         // Body uses normal C++ syntax.
         sum += factor * num;
         std::cout << "Summed: " << sum << std::endl;

Copied: sandbox/local/libs/local/example/add_using_local_functor.cpp (from r70637, /sandbox/local/libs/local/example/add_local_class.cpp)
==============================================================================
--- /sandbox/local/libs/local/example/add_local_class.cpp (original)
+++ sandbox/local/libs/local/example/add_using_local_functor.cpp 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
@@ -4,7 +4,7 @@
 // License, Version 1.0 (see accompanying file LICENSE_1_0.txt or a
 // copy at http://www.boost.org/LICENSE_1_0.txt).
 
-//[ add_local_class_cpp
+//[ add_using_local_functor_cpp
 #include <iostream>
 #include <vector>
 #include <algorithm>
@@ -16,21 +16,22 @@
     std::vector<double> v(3);
     v[0] = 1.0; v[1] = 2.0; v[2] = 3.0;
 
- struct local {
- static void add(double num,
- // Unfortunately, cannot bind so repeat local variable types.
- double& sum, const int& factor) {
- // Body uses normal C++ syntax.
+ struct local_add { // Unfortunately, boilerplate code to program the class.
+ local_add(double& _sum, int _factor): sum(_sum), factor(_factor) {}
+
+ void operator()(double num) { // Body uses C++ statement syntax.
             sum += factor * num;
             std::cout << "Summed: " << sum << std::endl;
         }
- };
+
+ private:
+ // Unfortunately, cannot bind so repeat variable types.
+ double& sum; // Access `sum` by reference.
+ const int factor; // Make `factor` constant.
+ } add(sum, factor);
 
     // Unfortunately, cannot pass as template parameter to `std::for_each`.
- for (size_t i = 0; i < v.size(); ++i) {
- // Unfortunately, explicitly pass variables `sum` and `factor`.
- local::add(v[i], sum, factor);
- }
+ for (size_t i = 0; i < v.size(); ++i) add(v[i]);
 
     std::cout << sum << std::endl;
     return 0;

Deleted: sandbox/local/libs/local/example/add_va.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_va.cpp 2011-04-03 13:54:11 EDT (Sun, 03 Apr 2011)
+++ (empty file)
@@ -1,56 +0,0 @@
-
-// Copyright (C) 2009-2011 Lorenzo Caminiti
-// 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).
-
-#include <boost/config.hpp>
-#if defined(BOOST_NO_VARIADIC_MACROS) || defined(BOOST_LOCAL_CONFIG_COMPLIANT)
-#include <iostream>
-int main() {
- std::cerr << "Error: This program requires variadic macros" << std::endl;
- return 0;
-}
-#else
-
-//[ add_va_cpp
-#include <boost/local/function.hpp>
-#include <boost/local/block.hpp>
-#include <boost/local/exit.hpp>
-
-#include <algorithm>
-#include <iostream>
-#include <cassert>
-
-int main() {
- double sum = 0.0;
- int factor = 10;
-
- void BOOST_LOCAL_FUNCTION_PARAMS(double num,
- const bind factor, bind& sum) {
- sum += factor * num;
- std::cout << "Summed: " << sum << std::endl;
- } BOOST_LOCAL_FUNCTION_NAME(add)
- add(100.0);
-
- size_t size = 2;
- double* nums = new double[size];
- BOOST_LOCAL_EXIT(const bind& size, bind nums) {
- if (size && nums) delete[] nums;
- std::cout << "Freed array: " << nums << std::endl;
- } BOOST_LOCAL_EXIT_END
-
- nums[0] = 90.5; nums[1] = 7.0;
- std::for_each(nums, nums + size, add); // `add` as template parameter
-
- BOOST_LOCAL_BLOCK(const bind& sum) {
- assert(sum == 1975.0); // so far `sum` is 10*100+10*90.5+10*7=1975
- std::cout << "Asserted summation: " << sum << std::endl;
- } BOOST_LOCAL_BLOCK_END
-
- return 0;
-}
-//]
-
-#endif
-


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