Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76714 - in sandbox/local_function: boost/local_function/aux_ libs/local_function/doc libs/local_function/doc/html libs/local_function/doc/html/boost_localfunction libs/local_function/test
From: lorcaminiti_at_[hidden]
Date: 2012-01-26 17:21:09


Author: lcaminiti
Date: 2012-01-26 17:21:08 EST (Thu, 26 Jan 2012)
New Revision: 76714
URL: http://svn.boost.org/trac/boost/changeset/76714

Log:
Docs.
Properties modified:
   sandbox/local_function/libs/local_function/doc/ (props changed)
Text files modified:
   sandbox/local_function/boost/local_function/aux_/function.hpp | 4
   sandbox/local_function/libs/local_function/doc/alternatives.qbk | 255 +++++++------
   sandbox/local_function/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION.html | 2
   sandbox/local_function/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html | 2
   sandbox/local_function/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html | 2
   sandbox/local_function/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_NAME.html | 2
   sandbox/local_function/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TPL.html | 2
   sandbox/local_function/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TYPEOF.html | 2
   sandbox/local_function/libs/local_function/doc/html/boost_localfunction/Alternatives.html | 773 +++++++++++++++++++++++++++------------
   sandbox/local_function/libs/local_function/doc/html/index.html | 2
   sandbox/local_function/libs/local_function/doc/local_function.qbk | 11
   sandbox/local_function/libs/local_function/test/Jamfile.v2 | 4
   12 files changed, 691 insertions(+), 370 deletions(-)

Modified: sandbox/local_function/boost/local_function/aux_/function.hpp
==============================================================================
--- sandbox/local_function/boost/local_function/aux_/function.hpp (original)
+++ sandbox/local_function/boost/local_function/aux_/function.hpp 2012-01-26 17:21:08 EST (Thu, 26 Jan 2012)
@@ -312,6 +312,10 @@
 #endif
     BOOST_PP_REPEAT(BOOST_PP_INC(BOOST_LOCAL_FUNCTION_AUX_defaults),
             BOOST_LOCAL_FUNCTION_AUX_call_decl, ~) // INC for no defaults.
+
+ // run-time: this unused void* member variable allows for compiler
+ // optimizations (at least on MSVC it reduces invocation time of about 50%)
+ void* unused_;
 };
 
 # undef BOOST_LOCAL_FUNCTION_AUX_defaults

Modified: sandbox/local_function/libs/local_function/doc/alternatives.qbk
==============================================================================
--- sandbox/local_function/libs/local_function/doc/alternatives.qbk (original)
+++ sandbox/local_function/libs/local_function/doc/alternatives.qbk 2012-01-26 17:21:08 EST (Thu, 26 Jan 2012)
@@ -15,22 +15,20 @@
 [table
 [
     [ Local Function Feature ]
- [ Boost.Local (this library) ]
+ [ Boost.LocalFunction ]
+ [ C++11 Lambda Function (Not C++03) ]
     [ Local Functor ]
- [ Global Functor (not local) ]
- [ __CPP0x_Lambda__ (not __CPP03__) ]
- [ __Boost_Lambda__ ]
- [ __Boost_Phoenix__ ]
+ [ Global Functor (Not Local) ]
+ [ Boost.Phoenix ]
 ]
 [
     [ ['Can be defined locally] ]
     [ Yes. ]
     [ Yes. ]
+ [ Yes. ]
     [ No.
 Therefore this not really an alternative implementation of local functions but it is listed here just for comparison. ]
     [ Yes. ]
- [ Yes. ]
- [ Yes. ]
 ]
 [
     [ ['Can be defined using C++ statement syntax] ]
@@ -43,24 +41,21 @@
     [ Yes.
 Plus eventual compiler errors follow the usual format of C++ statement errors. ]
     [ No (it uses C++ __expression_template__ syntax). ]
- [ No (it uses C++ __expression_template__ syntax). ]
 ]
 [
     [ ['Can be defined within expressions] ]
     [ No. It can be defined only within declarations. ]
+ [ Yes (plus the local function can be unnamed). ]
     [ No. It can be defined only within declarations. ]
     [ No. It can be defined only within declarations. ]
     [ Yes (plus the local function can be unnamed). ]
- [ Yes (plus the local function can be unnamed). ]
- [ Yes (plus the local function can be unnamed). ]
 ]
 [
     [ ['Can be passed as template parameter (e.g., to STL algorithms)] ]
     [ Yes.
 The __CPP03__ standard does not allow to pass local types as template parameters (see __N2657__) but this library implements a "trick" to get around this limitation (see the __Implementation__ section). ]
- [ No on __CPP03__ compilers (but yes on __CPP11__ compilers and some compilers like MSVC 8.0, see __N2657__). ]
- [ Yes. ]
     [ Yes. ]
+ [ No on __CPP03__ compilers (but yes on __CPP11__ compilers and some compilers like MSVC 8.0, see __N2657__). ]
     [ Yes. ]
     [ Yes. ]
 ]
@@ -68,168 +63,190 @@
     [ ['Access variables in scope] ]
     [ Yes.
 The variable names are repeated in the function declaration so they can be bound by value, by constant value, by reference, and by constant reference (the object `this` can also be bound). ]
+ [ Yes.
+The variable names are repeated in the function declaration (plus there is a short-hand syntax to bind all variables in scope at once) so they can be bound by constant value and by reference (the object `this` can also be bound).
+However, variables cannot be bound by constant references and non-constant value (see below). ]
     [ No.
 Programmers must manually manage functor member variables and explicitly specify their types to access variables in scope. ]
     [ No.
 Programmers must manually manage functor member variables and explicitly specify their types to access variables in scope. ]
- [ Yes.
-The variable names are repeated in the function declaration (plus there is a short-hand syntax to bind all variables in scope at once) so they can be bound by constant value and by reference (the object `this` can also be bound).
-However, variables cannot be bound by constant references and non-constant value (see below). ]
- [ Yes (variables in scope are accessible as usual within expressions). ]
     [ Yes (variables in scope are accessible as usual within expressions) plus `boost::phoenix::let` can be used to bind variables by constant reference. ]
 ]
 [
     [ ['[@http://en.wikipedia.org/wiki/Type_polymorphism#Parametric_polymorphism Polymorphic] in the unbound parameter types] ]
     [ No (local functions cannot be function templates). ]
- [ No (local classes cannot have member function templates). ]
- [ Yes. ]
     [ No (__CPP11__ lambdas cannot be function templates). ]
+ [ No (local classes cannot have member function templates). ]
     [ Yes. ]
     [ Yes. ]
 ]
 ]
 
-[h5 Comparison with __CPP0x_Lambda__ Functions]
+[*C++11 Lambda Function]
 
-__CPP0x_lambda__ functions have most of the features that __Boost_Local__ local functions have, key pro and cons of the two approaches are:
+__CPP11_lambda__ functions have most of the features of this library (see also the example in the __Introduction__ section):
 
-* __CPP0x_lambda__ functions can be defined within expressions while __Boost_Local__ local functions can only be defined within declarations.
-* __CPP0x_lambda__ functions are only supported by the __CPP11__ standard so they are not supported by all C++ compilers.
-__Boost_Local__ local functions use only __CPP03__ compliant features so they are supported on all C++ compliant compilers.
-* __CPP0x_lambda__ functions do not allow to bind variables in scope by constant reference or by non-constant value.
-Because a variable cannot be bound by constant reference, __CPP0x_lambda__ functions can bind a variable by constant only if the variable is copyable and the binding requires a (potentially expensive) extra copy operation.
-Both constant reference and non-constant value binding are instead supported by __Boost_Local__.
+* __CPP11_lambda__ functions can be defined within expressions while this library local functions can only be defined at declaration scope.
+* __CPP11_lambda__ functions are only supported by the __CPP11__ standard so they are not supported by all C++ compilers.
+This library local functions can be programmed also on __CPP03__ compilers (and they have performances comparable to __CPP11_lambda__ functions on __CPP11__ compilers).
+* __CPP11_lambda__ functions do not allow to bind variables in scope by constant reference or by non-constant value.
+Because a variable cannot be bound by constant reference, __CPP11_lambda__ functions can bind a variable by constant only if the variable is `CopyConstructible` and the binding requires a (potentially expensive) extra copy operation.
+Both constant reference and non-constant value binding are instead supported by this library.
 
-For example, for non-copyable objects:
+For example, for non-copyable objects (see also [@../../example/noncopyable_lambda.cpp =noncopyable_lambda.cpp=] and [@../../example/noncopyable_local_function.cpp =noncopyable_local_function.cpp=]):
 
 [table
-[ [__CPP0x_Lambda__] [__Boost_Local__ __Variadic_Macro_Syntax__] [__Boost_Local__ __Sequencing_Macro_Syntax__] ]
-[ [ [noncopyable_0x_lambda_cpp] ] [ [noncopyable_boost_local_va_cpp] ] [ [noncopyable_boost_local_cpp] ] ]
+ [ [C++11 Lambda] [Boost.LocalFunction] ]
+ [ [[noncopyable_lambda]] [[noncopyable_local_function]] ]
 ]
 
-Or, for objects with expensive copy operations:
+Or, for objects with expensive copy operations (see also [@../../example/expensive_copy_lambda.cpp =expensive_copy_lambda.cpp=] and [@../../example/expensive_copy_local_function.cpp =expensive_copy_local_function.cpp=]):
 
 [table
-[ [__CPP0x_Lambda__] [__Boost_Local__ __Variadic_Macro_Syntax__] [__Boost_Local__ __Sequencing_Macro_Syntax__] ]
-[ [ [expensive_copy_0x_lambda_cpp] ] [ [expensive_copy_boost_local_va_cpp] ] [ [expensive_copy_boost_local_cpp] ] ]
+ [ [C++11 Lambda] [Boost.LocalFunction] ]
+ [ [[expensive_copy_lambda]] [[expensive_copy_local_function]] ]
 ]
 
-[h5 Examples]
+Note that when constant binding functionality is needed for __CPP11_lambda__ functions, the best alternative might be to bind an extra local variable declared constant and initialized to the original variable (for example, `const n& const_x = x;` and then bind `const_x` instead of `x` to the lambda function).
+In many cases the use of the extra constant variable `const_x` can be acceptable but in other cases (e.g., /constant blocks/ presented in the __Examples__ section) it might be preferable to maintain the same variable name `x` within the function body.
+
+[*Local Functor]
 
-The same example is rewritten here for all the different alternatives to local functions so programmers can get a sense of the different syntaxes and programming styles that the alternatives require.
-The following example adds together all the elements of a vector using this library local functions:
+The following example compares local functions with C++ local functors (see also [@../../example/add_local_functor.cpp =add_local_functor.cpp=] and [@../../test/add.cpp =add.cpp=]):
 
 [table
-[ [__Variadic_Macro_Syntax__] [__Sequencing_Macro_Syntax__] ]
-[ [ [add_using_boost_local_va_cpp] ] [ [add_using_boost_local_cpp] ] ]
+ [ [Local Functor] [Boost.LocalFunction] ]
+ [ [[add_local_functor]] [[test_add]] ]
 ]
 
-Or using C++ local functors:
-
-[add_using_local_functor_cpp]
+[*Global Functor]
 
-Or using C++ global functors (but these do not allow to define the function locally so they are not a real alternative implementation of local functions):
+The following example compares local functions with C++ global functors (see also [@../../example/add_global_functor.cpp =add_global_functor.cpp=] and [@../../test/add.cpp =add.cpp=]):
 
-[add_using_global_functor_cpp]
-
-Or using __CPP0x_lambda__ functions (but not part of the __CPP03__ standard):
+[table
+ [ [Global Functor] [Boost.LocalFunction] ]
+ [ [[add_global_functor]] [[test_add]] ]
+]
 
-[add_using_cpp0x_lambda_cpp]
+However, note that global functors do not allow to define the function locally so they are not a real alternative implementation of local functions.
 
-Or using __Boost_Lambda__ functions:
+[*Boost.Phoenix]
 
-[add_using_boost_lambda_cpp]
+The following example compares local functions with __Boost_Phoenix__ (see also [@../../example/add_phoenix.cpp =add_phoenix.cpp=] and [@../../test/add.cpp =add.cpp=]):
 
-Or using __Boost_Phoenix__:
+[table
+ [ [Boost.Phoenix] [Boost.LocalFunction] ]
+ [ [[add_phoenix]] [[test_add]] ]
+]
 
-[add_using_boost_phoenix_cpp]
+The comparison in this section does not include the __Boost_Lambda__ library because it is obsolete and it was replaced replaced by __Boost_Phoenix__.
+The __Boost_Phoenix__ library version 3.0 is used for this comparison.
 
 [h5 Performances]
 
-The following tables compare run-times, compile-times, and binary sizes for the different alternatives presented so far for local functions.
+The following tables compare run-times, compile-times, and binary sizes for the different alternatives presented here for local functions.
 
 Overall, this library has compile-times and generates binary sizes similar to the ones of the other approaches.
-This library run-times on __CPP03__ compliant compilers (see "__Boost_Local__ Compliant" below) were measured to be larger than other approaches when compiler optimization is enabled (using `bjam release ...`).
-However, on compilers that allow to pass local types as template parameters (e.g., MSVC 8.0 or GCC 4.5.1 with __CPP11__ features enabled, see also __N2657__) this library automatically generates optimized code that runs as fast as the fastest of the other approaches (see "__Boost_Local__" below).
-When this library local function is specified `inline` (see "__Boost_Local__ Inline For-Loop" below and the __Advanced_Topics__ section) its run-times are always comparable to both the "Local Functor" and "Global Functor" approaches (but in this case the local function cannot be portably passed as template parameter, see __N2657__, so `std::for_each` is replaced by a for-loop).
+This library run-times on __CPP03__ compliant compilers were measured to be larger than other approaches when compiler optimization is enabled (using `bjam release ...`).
+However, on compilers that allow to pass local types as template parameters (e.g., MSVC 8.0 or GCC 4.5.3 with __CPP11__ features enabled [^-std=c++0x], see also __N2657__) this library automatically generates optimized code that runs as fast as the fastest of the other approaches (see __Boost_LocalFunction__ below).
+When this library local function is specified `inline` (see __Boost_LocalFunction__ Inline below and the __Advanced_Topics__ section) its run-times are always comparable to both the Local Functor and Global Functor approaches (but in this case the local function cannot be portably passed as template parameter, see __N2657__, so `std::for_each` is replaced by a for-loop).
 Finally, this library run-times are always among the fastest when no compiler optimization is enabled (using `bjam debug ...`).
 
 [note
-The run-time performances of this library local functions are explained because on __CPP03__ compliant compilers (e.g., GCC 4.3.4) this library needs to use a function pointer in order to pass the local function class as a template parameter (see __N2657__ and the __Implementation__ section).
+The run-time performances of this library local functions are explained because on __CPP03__ compliant compilers (e.g., GCC 4.5.3 without [^-std=c++0x]) this library needs to use a function pointer in order to pass the local function class as a template parameter (see __N2657__ and the __Implementation__ section).
 For all tested compilers, this function pointer prevents the compiler optimization algorithms from inlining the local function calls.
-Instead, the functors used by other approaches like "__Boost_Lambda__" and "__Boost_Phoenix__" have been observed to allow all tested compilers to inline all the function calls for optimization.
-This run-time performance cost is not present on compilers that allow to pass local types as template parameters (e.g., MSVC 8.0 or GCC 4.5.1 with __CPP11__ features enabled) because this library does not have to use the extra function pointer to implement the local function call (it directly passes the local class type as template parameter).
+Instead, the functors used by other approaches (e.g., __Boost_Phoenix__) have been observed to allow all tested compilers to inline all the function calls for optimization.
+This run-time performance cost is not present on compilers that allow to pass local types as template parameters (e.g., MSVC 8.0 or GCC 4.5.3 with __CPP11__ features enabled [^-std=c++0x]) because this library does not have to use the extra function pointer to implement the local function call (it directly passes the local class type as template parameter).
 ]
 
 This run-time performance cost on __CPP03__ compliant compilers might or might not be an issue depending on the performance requirements of specific applications.
 For example, an application might already be using a number of indirect function calls (function pointers, virtual functions, etc) for which the overhead added by using the one extra function pointer required by the local function call might not be noticeable within the overall program run-time.
 
-Finally, note that only a very simple local function body with just a single instruction was used for the anaylsis presented here (see the `profile_...` source files linked below).
-The authors have not studied how this library and the other approaches will perform with respect to each other when a more complex set of instructions is programmed for the local function body (e.g., /if/ a more complex set of instructions in the local function body were to inhibit some compilers from inlining functor objects also other approaches like __Boost_Lambda__ and __Boost_Phoenix__ /could/ start to show higher run-times even when optimization is enabled).
+Finally, note that only a very simple local function body with just a single instruction was used for the anaylsis presented here (see the source files below).
+The authors have not studied how this library and the other approaches will perform with respect to each other when a more complex set of instructions is programmed for the local function body (e.g., /if/ a more complex set of instructions in the local function body were to inhibit some compilers from inlining functor objects also other approaches like __Boost_Phoenix__ /could/ start to show higher run-times even when optimization is enabled).
 
-[table
-[ [ Legend, Source Files, and Commands ] ]
-[ [ [$../../example/profile_legend.png [width 13in] [height 10in]] ] ]
-[ [
-The local function was called =1e8= times to add together all the elements of a vector and the run-time was measured using __Boost_Chrono__ averaging over =10= executions of the vector summation (see source files
-[@../../example/profile_boost_local.cpp =profile_boost_local.cpp=],
-[@../../example/profile_boost_local_inline.cpp =profile_boost_local_inline.cpp=],
-[@../../example/profile_local_functor.cpp =profile_local_functor.cpp=],
-[@../../example/profile_global_functor.cpp =profile_global_functor.cpp=],
-[@../../example/profile_0x_lambda.cpp =profile_0x_lambda.cpp=],
-[@../../example/profile_boost_lambda.cpp =profile_boost_lambda.cpp=], and
-[@../../example/profile_boost_phoenix.cpp =profile_boost_phoenix.cpp=]).
-] ]
-[ [
 The following commands were executed from the library example directory to measure compile-time, binary size, and run-time respectively:
-``
-> python chrono.py bjam {release|debug} <PROGRAM> # compile-time
-> size <PROGRAM> # binary size (Linux and Gygwin)
-> <PROGRAM> # run-time
-``
-] ]
-]
-
-[table
-[ [
-GCC 4.5.1 With __CPP11__ Lambdas and "Local Types as Template Parameters" ([^bjam cxxflags=-std=c++0x ...]) on Ubuntu Linux 10
-] ]
-[ [
-[*Compiled with =bjam release ...= for maximum optimization (=-O3 -finline-functions=)]
-[$../../example/profile_gcc-4.5.1-0x_release.png [width 13in] [height 10in]]
-] ]
-[ [
-[*Compiled with =bjam debug ...= for no optimization (=-O0 -fno-inline=)]
-[$../../example/profile_gcc-4.5.1-0x_debug.png [width 13in] [height 10in]]
-] ]
-]
 
-[table
-[ [
-MSVC 8.0 With "Local Types as Template Parameters" (Without __CPP11__ Lambdas) on Windows XP
-] ]
-[ [
-[*Compiled with =bjam release ...= for maximum optimization (=/O2 /Ob2=)]
-[$../../example/profile_msvc-8.0_release.png [width 13in] [height 10in]]
-] ]
-[ [
-[*Compiled with =bjam debug ...= for no optimization (=/Od /Ob0=)]
-[$../../example/profile_msvc-8.0_debug.png [width 13in] [height 10in]]
-] ]
-]
-
-[table
-[ [
-GCC 4.3.4 With __CPP03__ Only (Without __CPP11__ Lambdas and Without "Local Types as Template Parameters) on Cygwin
-] ]
-[ [
-[*Compiled with =bjam release ...= for maximum optimization (=-O3 -finline-functions=)]
-[$../../example/profile_gcc-4.3.4_release.png [width 13in] [height 10in]]
-] ]
-[ [
-[*Compiled with =bjam debug ...= for no optimization (=-O0 -fno-inline=)]
-[$../../example/profile_gcc-4.3.4_debug.png [width 13in] [height 10in]]
-] ]
+[pre
+> python chrono.py bjam {release|debug} <PROGRAM> # compile-time
+> size <PROGRAM> # binary size (Linux and Gygwin)
+> <PROGRAM> # run-time
+]
+
+The local function was called =1e8= times to add together all the elements of a vector and the run-time was measured using __Boost_Chrono__ averaging over =10= executions of the vector summation (see the source files below).
+
+[table
+ [
+ [Legend]
+ [Approach]
+ [File]
+ ]
+ [
+ [[$../../example/profile_legend_local_function.png]]
+ [__Boost_LocalFunction__]
+ [[@../../example/profile_local_function.cpp =profile_local_function.cpp=]]
+ ]
+ [
+ [[$../../example/profile_legend_local_function_inline.png]]
+ [__Boost_LocalFunction__ inline]
+ [[@../../example/profile_local_function_inline.cpp =profile_local_function_inline.cpp=]]
+ ]
+ [
+ [[$../../example/profile_legend_lambda.png]]
+ [__CPP11__ Lambda Function]
+ [[@../../example/profile_lambda.cpp =profile_lambda.cpp=]]
+ ]
+ [
+ [[$../../example/profile_legend_local_functor.png]]
+ [Local Functor]
+ [[@../../example/profile_local_functor.cpp =profile_local_functor.cpp=]]
+ ]
+ [
+ [[$../../example/profile_legend_global_functor.png]]
+ [Global Functor]
+ [[@../../example/profile_global_functor.cpp =profile_global_functor.cpp=]]
+ ]
+ [
+ [[$../../example/profile_legend_phoenix.png]]
+ [__Boost_Phoenix__]
+ [[@../../example/profile_phoenix.cpp =profile_phoenix.cpp=]]
+ ]
+]
+
+[table
+ [ [GCC 4.5.3 With C++11 Lambdas and "Local Types as Template Parameters" ([^bjam cxxflags=-std=c++0x ...])] ]
+ [ [
+ [*Compiled with =bjam release ...= for maximum optimization (=-O3 -finline-functions=)]
+ [$../../example/profile_gcc_cpp11_release.png [width 13in] [height 10in]]
+ ] ]
+ [ [
+ [*Compiled with =bjam debug ...= for no optimization (=-O0 -fno-inline=)]
+ [$../../example/profile_gcc_cpp11_debug.png [width 13in] [height 10in]]
+ ] ]
+]
+
+[table
+ [ [MSVC 8.0 With "Local Types as Template Parameters" (Without __CPP11__ Lambdas)] ]
+ [ [
+ [*Compiled with =bjam release ...= for maximum optimization (=/O2 /Ob2=)]
+ [$../../example/profile_msvc_release.png [width 13in] [height 10in]]
+ ] ]
+ [ [
+ [*Compiled with =bjam debug ...= for no optimization (=/Od /Ob0=)]
+ [$../../example/profile_msvc_debug.png [width 13in] [height 10in]]
+ ] ]
+]
+
+[table
+ [ [GCC 4.3.4 With __CPP03__ Only (Without __CPP11__ Lambdas and Without "Local Types as Template Parameters")] ]
+ [ [
+ [*Compiled with =bjam release ...= for maximum optimization (=-O3 -finline-functions=)]
+ [$../../example/profile_gcc_release.png [width 13in] [height 10in]]
+ ] ]
+ [ [
+ [*Compiled with =bjam debug ...= for no optimization (=-O0 -fno-inline=)]
+ [$../../example/profile_gcc_debug.png [width 13in] [height 10in]]
+ ] ]
 ]
 
 [endsect]

Modified: sandbox/local_function/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION.html
==============================================================================
--- sandbox/local_function/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION.html (original)
+++ sandbox/local_function/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION.html 2012-01-26 17:21:08 EST (Thu, 26 Jan 2012)
@@ -33,7 +33,7 @@
 
 </span>BOOST_LOCAL_FUNCTION(declarations)</pre></div>
 <div class="refsect1">
-<a name="id834350"></a><h2>Description</h2>
+<a name="id829980"></a><h2>Description</h2>
 <p>This macro must be used within a declarative context, it must follow the local function result type, it must be followed by the local function body code, and then by the <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code> macro (see the <a class="link" href="boost_localfunction/Tutorial.html" title="Tutorial">Tutorial</a> and <a class="link" href="boost_localfunction/Advanced_Topics.html" title="Advanced Topics"> Advanced Topics</a> sections): </p>
 <pre class="programlisting"><span class="special">{</span> <span class="comment">// Some declarative context.</span>
     <span class="special">...</span>

Modified: sandbox/local_function/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html
==============================================================================
--- sandbox/local_function/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html (original)
+++ sandbox/local_function/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html 2012-01-26 17:21:08 EST (Thu, 26 Jan 2012)
@@ -33,7 +33,7 @@
 
 </span>BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX</pre></div>
 <div class="refsect1">
-<a name="id836784"></a><h2>Description</h2>
+<a name="id832415"></a><h2>Description</h2>
 <p>If programmers leave this configuration macro undefined, its default value is <code class="computeroutput">5</code> (increasing this number might increase compilation time). When defined by programmers, this macro must be a non-negative integer number.</p>
 <p><span class="bold"><strong>Note:</strong></span> This macro specifies the maximum number of local function parameters excluding bound variables (which are instead specified by <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX">BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX</a></code>).</p>
 <p><span class="bold"><strong>See:</strong></span> <a class="link" href="boost_localfunction/Tutorial.html" title="Tutorial">Tutorial</a> section, <a class="link" href="boost_localfunction/Getting_Started.html" title="Getting Started"> Getting Started</a> section, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX">BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX</a></code>. </p>

Modified: sandbox/local_function/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html
==============================================================================
--- sandbox/local_function/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html (original)
+++ sandbox/local_function/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html 2012-01-26 17:21:08 EST (Thu, 26 Jan 2012)
@@ -33,7 +33,7 @@
 
 </span>BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX</pre></div>
 <div class="refsect1">
-<a name="id836858"></a><h2>Description</h2>
+<a name="id832489"></a><h2>Description</h2>
 <p>If programmers leave this configuration macro undefined, its default value is <code class="computeroutput">10</code> (increasing this number might increase compilation time). When defined by programmers, this macro must be a non-negative integer number.</p>
 <p><span class="bold"><strong>Note:</strong></span> This macro specifies the maximum number of bound variables excluding local function parameters (which are instead specified by <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX">BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX</a></code>).</p>
 <p><span class="bold"><strong>See:</strong></span> <a class="link" href="boost_localfunction/Tutorial.html" title="Tutorial">Tutorial</a> section, <a class="link" href="boost_localfunction/Getting_Started.html" title="Getting Started"> Getting Started</a> section, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX">BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX</a></code>. </p>

Modified: sandbox/local_function/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_NAME.html
==============================================================================
--- sandbox/local_function/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_NAME.html (original)
+++ sandbox/local_function/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_NAME.html 2012-01-26 17:21:08 EST (Thu, 26 Jan 2012)
@@ -33,7 +33,7 @@
 
 </span>BOOST_LOCAL_FUNCTION_NAME(qualified_function_name)</pre></div>
 <div class="refsect1">
-<a name="id836274"></a><h2>Description</h2>
+<a name="id831905"></a><h2>Description</h2>
 <p>This macro must follow the local function body code block <code class="computeroutput">{ ... }</code>: </p>
 <pre class="programlisting"><span class="special">{</span> <span class="comment">// Some declarative context.</span>
     <span class="special">...</span>

Modified: sandbox/local_function/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TPL.html
==============================================================================
--- sandbox/local_function/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TPL.html (original)
+++ sandbox/local_function/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TPL.html 2012-01-26 17:21:08 EST (Thu, 26 Jan 2012)
@@ -33,7 +33,7 @@
 
 </span>BOOST_LOCAL_FUNCTION_TPL(declarations)</pre></div>
 <div class="refsect1">
-<a name="id836096"></a><h2>Description</h2>
+<a name="id831727"></a><h2>Description</h2>
 <p>This macro must be used instead of <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code> when declaring a local function within a template. A part from that, this macro has the exact same syntax as <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code> (see <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code> for more information): </p>
 <pre class="programlisting"><span class="special">{</span> <span class="comment">// Some declarative context with a template.</span>
     <span class="special">...</span>

Modified: sandbox/local_function/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TYPEOF.html
==============================================================================
--- sandbox/local_function/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TYPEOF.html (original)
+++ sandbox/local_function/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TYPEOF.html 2012-01-26 17:21:08 EST (Thu, 26 Jan 2012)
@@ -33,7 +33,7 @@
 
 </span>BOOST_LOCAL_FUNCTION_TYPEOF(bound_variable_name)</pre></div>
 <div class="refsect1">
-<a name="id836584"></a><h2>Description</h2>
+<a name="id832214"></a><h2>Description</h2>
 <p>The type returned by the macro is fully qualified in that it contains the extra constant and reference qualifiers when the specified variable was bound by constant and by reference.</p>
 <p><span class="bold"><strong>Parameters:</strong></span> </p>
 <div class="informaltable"><table class="table">

Modified: sandbox/local_function/libs/local_function/doc/html/boost_localfunction/Alternatives.html
==============================================================================
--- sandbox/local_function/libs/local_function/doc/html/boost_localfunction/Alternatives.html (original)
+++ sandbox/local_function/libs/local_function/doc/html/boost_localfunction/Alternatives.html 2012-01-26 17:21:08 EST (Thu, 26 Jan 2012)
@@ -46,7 +46,6 @@
 <col>
 <col>
 <col>
-<col>
 </colgroup>
 <thead><tr>
 <th>
@@ -56,32 +55,27 @@
             </th>
 <th>
               <p>
- Boost.Local (this library)
- </p>
- </th>
-<th>
- <p>
- Local Functor
+ Boost.LocalFunction
               </p>
             </th>
 <th>
               <p>
- Global Functor (not local)
+ C++11 Lambda Function (Not C++03)
               </p>
             </th>
 <th>
               <p>
- __CPP0x_Lambda__ (not C++03)
+ Local Functor
               </p>
             </th>
 <th>
               <p>
- Boost.Lambda
+ Global Functor (Not Local)
               </p>
             </th>
 <th>
               <p>
- Boost.Phoenix
+ Boost.Phoenix
               </p>
             </th>
 </tr></thead>
@@ -104,18 +98,13 @@
             </td>
 <td>
               <p>
- No. Therefore this not really an alternative implementation of local
- functions but it is listed here just for comparison.
- </p>
- </td>
-<td>
- <p>
                 Yes.
               </p>
             </td>
 <td>
               <p>
- Yes.
+ No. Therefore this not really an alternative implementation of local
+ functions but it is listed here just for comparison.
               </p>
             </td>
 <td>
@@ -160,12 +149,6 @@
                 template</a> syntax).
               </p>
             </td>
-<td>
- <p>
- No (it uses C++ <a href="http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Expression-template" target="_top">expression
- template</a> syntax).
- </p>
- </td>
 </tr>
 <tr>
 <td>
@@ -180,7 +163,7 @@
             </td>
 <td>
               <p>
- No. It can be defined only within declarations.
+ Yes (plus the local function can be unnamed).
               </p>
             </td>
 <td>
@@ -190,12 +173,7 @@
             </td>
 <td>
               <p>
- Yes (plus the local function can be unnamed).
- </p>
- </td>
-<td>
- <p>
- Yes (plus the local function can be unnamed).
+ No. It can be defined only within declarations.
               </p>
             </td>
 <td>
@@ -222,19 +200,14 @@
             </td>
 <td>
               <p>
- No on C++03
- compilers (but yes on C++11
- compilers and some compilers like MSVC 8.0, see [N2657]).
- </p>
- </td>
-<td>
- <p>
                 Yes.
               </p>
             </td>
 <td>
               <p>
- Yes.
+ No on C++03
+ compilers (but yes on C++11
+ compilers and some compilers like MSVC 8.0, see [N2657]).
               </p>
             </td>
 <td>
@@ -264,18 +237,6 @@
             </td>
 <td>
               <p>
- No. Programmers must manually manage functor member variables and
- explicitly specify their types to access variables in scope.
- </p>
- </td>
-<td>
- <p>
- No. Programmers must manually manage functor member variables and
- explicitly specify their types to access variables in scope.
- </p>
- </td>
-<td>
- <p>
                 Yes. The variable names are repeated in the function declaration
                 (plus there is a short-hand syntax to bind all variables in scope
                 at once) so they can be bound by constant value and by reference
@@ -286,7 +247,14 @@
             </td>
 <td>
               <p>
- Yes (variables in scope are accessible as usual within expressions).
+ No. Programmers must manually manage functor member variables and
+ explicitly specify their types to access variables in scope.
+ </p>
+ </td>
+<td>
+ <p>
+ No. Programmers must manually manage functor member variables and
+ explicitly specify their types to access variables in scope.
               </p>
             </td>
 <td>
@@ -311,18 +279,13 @@
             </td>
 <td>
               <p>
- No (local classes cannot have member function templates).
- </p>
- </td>
-<td>
- <p>
- Yes.
+ No (C++11
+ lambdas cannot be function templates).
               </p>
             </td>
 <td>
               <p>
- No (C++11
- lambdas cannot be function templates).
+ No (local classes cannot have member function templates).
               </p>
             </td>
 <td>
@@ -338,219 +301,453 @@
 </tr>
 </tbody>
 </table></div>
-<h6>
-<a name="boost_localfunction.Alternatives.h1"></a>
- <span><a name="boost_localfunction.Alternatives.comparison_with___cpp0x_lambda___functions"></a></span><a class="link" href="Alternatives.html#boost_localfunction.Alternatives.comparison_with___cpp0x_lambda___functions">Comparison
- with __CPP0x_Lambda__ Functions</a>
- </h6>
 <p>
- __CPP0x_lambda__ functions have most of the features that __Boost_Local__ local
- functions have, key pro and cons of the two approaches are:
+ <span class="bold"><strong>C++11 Lambda Function</strong></span>
+ </p>
+<p>
+ <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda</a> functions have most of the features of this library (see also
+ the example in the <a class="link" href="../index.html#boost_localfunction.Introduction" title="Introduction">Introduction</a>
+ section):
     </p>
 <div class="itemizedlist"><ul class="itemizedlist" type="disc">
 <li class="listitem">
- __CPP0x_lambda__ functions can be defined within expressions while __Boost_Local__
- local functions can only be defined within declarations.
+ <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda</a> functions can be defined within expressions while this library
+ local functions can only be defined at declaration scope.
         </li>
 <li class="listitem">
- __CPP0x_lambda__ functions are only supported by the C++11
- standard so they are not supported by all C++ compilers. __Boost_Local__
- local functions use only C++03
- compliant features so they are supported on all C++ compliant compilers.
+ <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda</a> functions are only supported by the C++11
+ standard so they are not supported by all C++ compilers. This library local
+ functions can be programmed also on C++03
+ compilers (and they have performances comparable to <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda</a> functions on C++11
+ compilers).
         </li>
 <li class="listitem">
- __CPP0x_lambda__ functions do not allow to bind variables in scope by constant
+ <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda</a> functions do not allow to bind variables in scope by constant
           reference or by non-constant value. Because a variable cannot be bound
- by constant reference, __CPP0x_lambda__ functions can bind a variable by
- constant only if the variable is copyable and the binding requires a (potentially
- expensive) extra copy operation. Both constant reference and non-constant
- value binding are instead supported by __Boost_Local__.
+ by constant reference, <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda</a> functions can bind a variable by constant only if the variable
+ is <code class="computeroutput"><span class="identifier">CopyConstructible</span></code> and
+ the binding requires a (potentially expensive) extra copy operation. Both
+ constant reference and non-constant value binding are instead supported
+ by this library.
         </li>
 </ul></div>
 <p>
- For example, for non-copyable objects:
+ For example, for non-copyable objects (see also noncopyable_lambda.cpp
+ and noncopyable_local_function.cpp):
     </p>
 <div class="informaltable"><table class="table">
-<colgroup><col></colgroup>
+<colgroup>
+<col>
+<col>
+</colgroup>
 <thead><tr>
 <th>
               <p>
- __CPP0x_Lambda__
- </p>
- </th>
-<th>
- <p>
- __Boost_Local__ __Variadic_Macro_Syntax__
+ C++11 Lambda
               </p>
             </th>
 <th>
               <p>
- __Boost_Local__ __Sequencing_Macro_Syntax__
+ Boost.LocalFunction
               </p>
             </th>
 </tr></thead>
-<tbody>
-<tr><td>
- <p>
- [noncopyable_0x_lambda_cpp
- </p>
- </td></tr>
-<tr><td>
+<tbody><tr>
+<td>
               <p>
- noncopyable_boost_local_va_cpp
+</p>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">struct</span> <span class="identifier">n</span><span class="special">:</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">noncopyable</span> <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">i</span><span class="special">;</span>
+ <span class="identifier">n</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">_i</span><span class="special">):</span> <span class="identifier">i</span><span class="special">(</span><span class="identifier">_i</span><span class="special">)</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="keyword">void</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">n</span> <span class="identifier">x</span><span class="special">(-</span><span class="number">1</span><span class="special">);</span>
+
+ <span class="keyword">auto</span> <span class="identifier">f</span> <span class="special">=</span> <span class="special">[</span><span class="identifier">x</span><span class="special">](</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Error: x is non-copyable, but if</span>
+ <span class="identifier">assert</span><span class="special">(</span> <span class="identifier">x</span><span class="special">.</span><span class="identifier">i</span> <span class="special">==</span> <span class="special">-</span><span class="number">1</span> <span class="special">);</span> <span class="comment">// bind `&amp;x` then `x` is not constant.</span>
+ <span class="special">};</span>
+ <span class="identifier">f</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>
- </td></tr>
-<tr><td>
+ </td>
+<td>
               <p>
- noncopyable_boost_local_cpp
+</p>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">struct</span> <span class="identifier">n</span><span class="special">:</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">noncopyable</span> <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">i</span><span class="special">;</span>
+ <span class="identifier">n</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">_i</span><span class="special">):</span> <span class="identifier">i</span><span class="special">(</span><span class="identifier">_i</span><span class="special">)</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="identifier">n</span> <span class="identifier">x</span><span class="special">(-</span><span class="number">1</span><span class="special">);</span>
+
+ <span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">&amp;</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// OK: No copy</span>
+ <span class="identifier">assert</span><span class="special">(</span> <span class="identifier">x</span> <span class="special">==</span> <span class="special">-</span><span class="number">1</span> <span class="special">);</span> <span class="comment">// and constant.</span>
+ <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">f</span><span class="special">)</span>
+ <span class="identifier">f</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>
- </td></tr>
-</tbody>
+ </td>
+</tr></tbody>
 </table></div>
 <p>
- ]
- </p>
-<p>
- Or, for objects with expensive copy operations:
+ Or, for objects with expensive copy operations (see also expensive_copy_lambda.cpp
+ and expensive_copy_local_function.cpp):
     </p>
 <div class="informaltable"><table class="table">
-<colgroup><col></colgroup>
+<colgroup>
+<col>
+<col>
+</colgroup>
 <thead><tr>
 <th>
               <p>
- __CPP0x_Lambda__
+ C++11 Lambda
               </p>
             </th>
 <th>
               <p>
- __Boost_Local__ __Variadic_Macro_Syntax__
+ Boost.LocalFunction
               </p>
             </th>
+</tr></thead>
+<tbody><tr>
+<td>
+ <p>
+</p>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">struct</span> <span class="identifier">n</span> <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">i</span><span class="special">;</span>
+ <span class="identifier">n</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">_i</span><span class="special">):</span> <span class="identifier">i</span><span class="special">(</span><span class="identifier">_i</span><span class="special">)</span> <span class="special">{}</span>
+ <span class="identifier">n</span><span class="special">(</span><span class="identifier">n</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">x</span><span class="special">):</span> <span class="identifier">i</span><span class="special">(</span><span class="identifier">x</span><span class="special">.</span><span class="identifier">i</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Some time consuming copy.</span>
+ <span class="keyword">for</span> <span class="special">(</span><span class="keyword">unsigned</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="number">10000</span><span class="special">;</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="char">'.'</span><span class="special">;</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="keyword">void</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">n</span> <span class="identifier">x</span><span class="special">(-</span><span class="number">1</span><span class="special">);</span>
+
+ <span class="keyword">auto</span> <span class="identifier">f</span> <span class="special">=</span> <span class="special">[</span><span class="identifier">x</span><span class="special">]()</span> <span class="special">{</span> <span class="comment">// Problem: Expensive copy, but if bind</span>
+ <span class="identifier">assert</span><span class="special">(</span> <span class="identifier">x</span><span class="special">.</span><span class="identifier">i</span> <span class="special">==</span> <span class="special">-</span><span class="number">1</span><span class="special">);</span> <span class="comment">// by `&amp;x` then `x` is not constant.</span>
+ <span class="special">};</span>
+ <span class="identifier">f</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>
+ </td>
+<td>
+ <p>
+</p>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">struct</span> <span class="identifier">n</span> <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">i</span><span class="special">;</span>
+ <span class="identifier">n</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">_i</span><span class="special">):</span> <span class="identifier">i</span><span class="special">(</span><span class="identifier">_i</span><span class="special">)</span> <span class="special">{}</span>
+ <span class="identifier">n</span><span class="special">(</span><span class="identifier">n</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">x</span><span class="special">):</span> <span class="identifier">i</span><span class="special">(</span><span class="identifier">x</span><span class="special">.</span><span class="identifier">i</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Some time consuming copy.</span>
+ <span class="keyword">for</span> <span class="special">(</span><span class="keyword">unsigned</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="number">10000</span><span class="special">;</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="char">'.'</span><span class="special">;</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="keyword">void</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">n</span> <span class="identifier">x</span><span class="special">(-</span><span class="number">1</span><span class="special">);</span>
+
+ <span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">&amp;</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// OK: No copy</span>
+ <span class="identifier">assert</span><span class="special">(</span> <span class="identifier">x</span><span class="special">.</span><span class="identifier">i</span> <span class="special">==</span> <span class="special">-</span><span class="number">1</span> <span class="special">);</span> <span class="comment">// and constant.</span>
+ <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">f</span><span class="special">)</span>
+ <span class="identifier">f</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>
+ </td>
+</tr></tbody>
+</table></div>
+<p>
+ Note that when constant binding functionality is needed for <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda</a> functions, the best alternative might be to bind an extra local
+ variable declared constant and initialized to the original variable (for example,
+ <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">n</span><span class="special">&amp;</span> <span class="identifier">const_x</span> <span class="special">=</span> <span class="identifier">x</span><span class="special">;</span></code>
+ and then bind <code class="computeroutput"><span class="identifier">const_x</span></code> instead
+ of <code class="computeroutput"><span class="identifier">x</span></code> to the lambda function).
+ In many cases the use of the extra constant variable <code class="computeroutput"><span class="identifier">const_x</span></code>
+ can be acceptable but in other cases (e.g., <span class="emphasis"><em>constant blocks</em></span>
+ presented in the <a class="link" href="Examples.html" title="Examples">Examples</a>
+ section) it might be preferable to maintain the same variable name <code class="computeroutput"><span class="identifier">x</span></code> within the function body.
+ </p>
+<p>
+ <span class="bold"><strong>Local Functor</strong></span>
+ </p>
+<p>
+ The following example compares local functions with C++ local functors (see
+ also add_local_functor.cpp
+ and add.cpp):
+ </p>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
 <th>
               <p>
- __Boost_Local__ __Sequencing_Macro_Syntax__
+ Local Functor
               </p>
             </th>
-</tr></thead>
-<tbody>
-<tr><td>
+<th>
               <p>
- [expensive_copy_0x_lambda_cpp
+ Boost.LocalFunction
               </p>
- </td></tr>
-<tr><td>
+ </th>
+</tr></thead>
+<tbody><tr>
+<td>
               <p>
- expensive_copy_boost_local_va_cpp
+</p>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span>
+
+ <span class="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">int</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">inline</span> <span class="keyword">void</span> <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">int</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="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">int</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="special">&amp;</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="identifier">add</span><span class="special">(</span><span class="number">1</span><span class="special">);</span>
+ <span class="keyword">int</span> <span class="identifier">nums</span><span class="special">[]</span> <span class="special">=</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">// 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="number">2</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">nums</span><span class="special">[</span><span class="identifier">i</span><span class="special">]);</span>
+
+ <span class="identifier">BOOST_CHECK</span><span class="special">(</span> <span class="identifier">sum</span> <span class="special">==</span> <span class="number">60</span> <span class="special">);</span>
+<span class="special">}</span>
+</pre>
+<p>
               </p>
- </td></tr>
-<tr><td>
+ </td>
+<td>
               <p>
- expensive_copy_boost_local_cpp
+</p>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="special">{</span> <span class="comment">// Some local scope.</span>
+ <span class="keyword">int</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span> <span class="comment">// Variables in scope to bind.</span>
+
+ <span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">factor</span><span class="special">,</span> <span class="identifier">bind</span><span class="special">&amp;</span> <span class="identifier">sum</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">num</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_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="number">1</span><span class="special">);</span> <span class="comment">// Call the local function.</span>
+ <span class="keyword">int</span> <span class="identifier">nums</span><span class="special">[]</span> <span class="special">=</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="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="number">2</span><span class="special">,</span> <span class="identifier">add</span><span class="special">);</span> <span class="comment">// Pass it to an algorithm.</span>
+
+ <span class="identifier">BOOST_CHECK</span><span class="special">(</span> <span class="identifier">sum</span> <span class="special">==</span> <span class="number">60</span> <span class="special">);</span> <span class="comment">// Assert final summation value.</span>
+<span class="special">}</span>
+</pre>
+<p>
               </p>
- </td></tr>
-</tbody>
+ </td>
+</tr></tbody>
 </table></div>
 <p>
- ]
+ <span class="bold"><strong>Global Functor</strong></span>
     </p>
-<h6>
-<a name="boost_localfunction.Alternatives.h2"></a>
- <span><a name="boost_localfunction.Alternatives.examples"></a></span><a class="link" href="Alternatives.html#boost_localfunction.Alternatives.examples">Examples</a>
- </h6>
 <p>
- The same example is rewritten here for all the different alternatives to local
- functions so programmers can get a sense of the different syntaxes and programming
- styles that the alternatives require. The following example adds together all
- the elements of a vector using this library local functions:
+ The following example compares local functions with C++ global functors (see
+ also add_global_functor.cpp
+ and add.cpp):
     </p>
 <div class="informaltable"><table class="table">
-<colgroup><col></colgroup>
+<colgroup>
+<col>
+<col>
+</colgroup>
 <thead><tr>
 <th>
               <p>
- __Variadic_Macro_Syntax__
+ Global Functor
               </p>
             </th>
 <th>
               <p>
- __Sequencing_Macro_Syntax__
+ Boost.LocalFunction
               </p>
             </th>
 </tr></thead>
-<tbody>
-<tr><td>
+<tbody><tr>
+<td>
               <p>
- [add_using_boost_local_va_cpp
+</p>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="comment">// Unfortunately, cannot be defined locally (so not real alternative).</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">int</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">inline</span> <span class="keyword">void</span> <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">int</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="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">int</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="special">&amp;</span> <span class="identifier">factor</span><span class="special">;</span> <span class="comment">// Make `factor` constant.</span>
+<span class="special">};</span>
+
+<span class="identifier">BOOST_AUTO_TEST_CASE</span><span class="special">(</span> <span class="identifier">add_global_functor</span> <span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span>
+
+ <span class="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">add</span><span class="special">(</span><span class="number">1</span><span class="special">);</span>
+ <span class="keyword">int</span> <span class="identifier">nums</span><span class="special">[]</span> <span class="special">=</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="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="number">2</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">BOOST_CHECK</span><span class="special">(</span> <span class="identifier">sum</span> <span class="special">==</span> <span class="number">60</span> <span class="special">);</span>
+<span class="special">}</span>
+</pre>
+<p>
               </p>
- </td></tr>
-<tr><td>
+ </td>
+<td>
               <p>
- add_using_boost_local_cpp
+</p>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="special">{</span> <span class="comment">// Some local scope.</span>
+ <span class="keyword">int</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span> <span class="comment">// Variables in scope to bind.</span>
+
+ <span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">factor</span><span class="special">,</span> <span class="identifier">bind</span><span class="special">&amp;</span> <span class="identifier">sum</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">num</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_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="number">1</span><span class="special">);</span> <span class="comment">// Call the local function.</span>
+ <span class="keyword">int</span> <span class="identifier">nums</span><span class="special">[]</span> <span class="special">=</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="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="number">2</span><span class="special">,</span> <span class="identifier">add</span><span class="special">);</span> <span class="comment">// Pass it to an algorithm.</span>
+
+ <span class="identifier">BOOST_CHECK</span><span class="special">(</span> <span class="identifier">sum</span> <span class="special">==</span> <span class="number">60</span> <span class="special">);</span> <span class="comment">// Assert final summation value.</span>
+<span class="special">}</span>
+</pre>
+<p>
               </p>
- </td></tr>
-</tbody>
+ </td>
+</tr></tbody>
 </table></div>
 <p>
- ]
- </p>
-<p>
- Or using C++ local functors:
- </p>
-<p>
- [add_using_local_functor_cpp]
- </p>
-<p>
- Or using C++ global functors (but these do not allow to define the function
- locally so they are not a real alternative implementation of local functions):
- </p>
-<p>
- [add_using_global_functor_cpp]
+ However, note that global functors do not allow to define the function locally
+ so they are not a real alternative implementation of local functions.
     </p>
 <p>
- Or using __CPP0x_lambda__ functions (but not part of the C++03
- standard):
+ <span class="bold"><strong>Boost.Phoenix</strong></span>
     </p>
 <p>
- [add_using_cpp0x_lambda_cpp]
- </p>
-<p>
- Or using Boost.Lambda
- functions:
+ The following example compares local functions with Boost.Phoenix
+ (see also add_phoenix.cpp
+ and add.cpp):
     </p>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ Boost.Phoenix
+ </p>
+ </th>
+<th>
+ <p>
+ Boost.LocalFunction
+ </p>
+ </th>
+</tr></thead>
+<tbody><tr>
+<td>
+ <p>
+</p>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span>
+ <span class="keyword">int</span> <span class="identifier">nums</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">// Passed to template, `factor` by constant, and defined in expression.</span>
+ <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</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="number">3</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="comment">// Access `sum` by reference.</span>
+ <span class="special">]);</span>
+
+ <span class="identifier">BOOST_CHECK</span><span class="special">(</span> <span class="identifier">sum</span> <span class="special">==</span> <span class="number">60</span> <span class="special">);</span>
+<span class="special">}</span>
+</pre>
 <p>
- [add_using_boost_lambda_cpp]
- </p>
+ </p>
+ </td>
+<td>
+ <p>
+</p>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="special">{</span> <span class="comment">// Some local scope.</span>
+ <span class="keyword">int</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span> <span class="comment">// Variables in scope to bind.</span>
+
+ <span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">factor</span><span class="special">,</span> <span class="identifier">bind</span><span class="special">&amp;</span> <span class="identifier">sum</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">num</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_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="number">1</span><span class="special">);</span> <span class="comment">// Call the local function.</span>
+ <span class="keyword">int</span> <span class="identifier">nums</span><span class="special">[]</span> <span class="special">=</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="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="number">2</span><span class="special">,</span> <span class="identifier">add</span><span class="special">);</span> <span class="comment">// Pass it to an algorithm.</span>
+
+ <span class="identifier">BOOST_CHECK</span><span class="special">(</span> <span class="identifier">sum</span> <span class="special">==</span> <span class="number">60</span> <span class="special">);</span> <span class="comment">// Assert final summation value.</span>
+<span class="special">}</span>
+</pre>
 <p>
- Or using Boost.Phoenix:
- </p>
+ </p>
+ </td>
+</tr></tbody>
+</table></div>
 <p>
- [add_using_boost_phoenix_cpp]
+ The comparison in this section does not include the Boost.Lambda
+ library because it is obsolete and it was replaced replaced by Boost.Phoenix.
+ The Boost.Phoenix
+ library version 3.0 is used for this comparison.
     </p>
 <h6>
-<a name="boost_localfunction.Alternatives.h3"></a>
+<a name="boost_localfunction.Alternatives.h1"></a>
       <span><a name="boost_localfunction.Alternatives.performances"></a></span><a class="link" href="Alternatives.html#boost_localfunction.Alternatives.performances">Performances</a>
     </h6>
 <p>
       The following tables compare run-times, compile-times, and binary sizes for
- the different alternatives presented so far for local functions.
+ the different alternatives presented here for local functions.
     </p>
 <p>
       Overall, this library has compile-times and generates binary sizes similar
       to the ones of the other approaches. This library run-times on C++03
- compliant compilers (see "__Boost_Local__ Compliant" below) were
- measured to be larger than other approaches when compiler optimization is enabled
- (using <code class="computeroutput"><span class="identifier">bjam</span> <span class="identifier">release</span>
- <span class="special">...</span></code>). However, on compilers that allow
- to pass local types as template parameters (e.g., MSVC 8.0 or GCC 4.5.1 with
- C++11 features
- enabled, see also [N2657])
+ compliant compilers were measured to be larger than other approaches when compiler
+ optimization is enabled (using <code class="computeroutput"><span class="identifier">bjam</span>
+ <span class="identifier">release</span> <span class="special">...</span></code>).
+ However, on compilers that allow to pass local types as template parameters
+ (e.g., MSVC 8.0 or GCC 4.5.3 with C++11
+ features enabled <code class="literal">-std=c++0x</code>, see also [N2657])
       this library automatically generates optimized code that runs as fast as the
- fastest of the other approaches (see "__Boost_Local__" below). When
- this library local function is specified <code class="computeroutput"><span class="keyword">inline</span></code>
- (see "__Boost_Local__ Inline For-Loop" below and the <a class="link" href="Advanced_Topics.html" title="Advanced Topics">Advanced
- Topics</a> section) its run-times are always comparable to both the "Local
- Functor" and "Global Functor" approaches (but in this case the
- local function cannot be portably passed as template parameter, see [N2657],
+ fastest of the other approaches (see Boost.LocalFunction
+ below). When this library local function is specified <code class="computeroutput"><span class="keyword">inline</span></code>
+ (see Boost.LocalFunction
+ Inline below and the <a class="link" href="Advanced_Topics.html" title="Advanced Topics">Advanced
+ Topics</a> section) its run-times are always comparable to both the Local
+ Functor and Global Functor approaches (but in this case the local function
+ cannot be portably passed as template parameter, see [N2657],
       so <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span></code> is replaced by a for-loop). Finally,
       this library run-times are always among the fastest when no compiler optimization
       is enabled (using <code class="computeroutput"><span class="identifier">bjam</span> <span class="identifier">debug</span>
@@ -564,21 +761,20 @@
 <tr><td align="left" valign="top"><p>
         The run-time performances of this library local functions are explained because
         on C++03
- compliant compilers (e.g., GCC 4.3.4) this library needs to use a function
- pointer in order to pass the local function class as a template parameter
- (see [N2657]
+ compliant compilers (e.g., GCC 4.5.3 without <code class="literal">-std=c++0x</code>)
+ this library needs to use a function pointer in order to pass the local function
+ class as a template parameter (see [N2657]
         and the <a class="link" href="Implementation.html" title="Annex: Implementation">Implementation</a>
         section). For all tested compilers, this function pointer prevents the compiler
         optimization algorithms from inlining the local function calls. Instead,
- the functors used by other approaches like "Boost.Lambda"
- and "Boost.Phoenix"
+ the functors used by other approaches (e.g., Boost.Phoenix)
         have been observed to allow all tested compilers to inline all the function
         calls for optimization. This run-time performance cost is not present on
         compilers that allow to pass local types as template parameters (e.g., MSVC
- 8.0 or GCC 4.5.1 with C++11
- features enabled) because this library does not have to use the extra function
- pointer to implement the local function call (it directly passes the local
- class type as template parameter).
+ 8.0 or GCC 4.5.3 with C++11
+ features enabled <code class="literal">-std=c++0x</code>) because this library does
+ not have to use the extra function pointer to implement the local function
+ call (it directly passes the local class type as template parameter).
       </p></td></tr>
 </table></div>
 <p>
@@ -592,65 +788,165 @@
     </p>
 <p>
       Finally, note that only a very simple local function body with just a single
- instruction was used for the anaylsis presented here (see the <code class="computeroutput"><span class="identifier">profile_</span><span class="special">...</span></code>
- source files linked below). The authors have not studied how this library and
- the other approaches will perform with respect to each other when a more complex
- set of instructions is programmed for the local function body (e.g., <span class="emphasis"><em>if</em></span>
- a more complex set of instructions in the local function body were to inhibit
- some compilers from inlining functor objects also other approaches like Boost.Lambda
- and Boost.Phoenix
+ instruction was used for the anaylsis presented here (see the source files
+ below). The authors have not studied how this library and the other approaches
+ will perform with respect to each other when a more complex set of instructions
+ is programmed for the local function body (e.g., <span class="emphasis"><em>if</em></span> a
+ more complex set of instructions in the local function body were to inhibit
+ some compilers from inlining functor objects also other approaches like Boost.Phoenix
       <span class="emphasis"><em>could</em></span> start to show higher run-times even when optimization
       is enabled).
     </p>
+<p>
+ The following commands were executed from the library example directory to
+ measure compile-time, binary size, and run-time respectively:
+ </p>
+<pre class="programlisting">&gt; python chrono.py bjam {release|debug} &lt;PROGRAM&gt; # compile-time
+&gt; size &lt;PROGRAM&gt; # binary size (Linux and Gygwin)
+&gt; &lt;PROGRAM&gt; # run-time
+</pre>
+<p>
+ The local function was called <code class="literal">1e8</code> times to add together
+ all the elements of a vector and the run-time was measured using Boost.Chrono
+ averaging over <code class="literal">10</code> executions of the vector summation (see
+ the source files below).
+ </p>
 <div class="informaltable"><table class="table">
-<colgroup><col></colgroup>
-<thead><tr><th>
+<colgroup>
+<col>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
               <p>
- Legend, Source Files, and Commands
+ Legend
               </p>
- </th></tr></thead>
+ </th>
+<th>
+ <p>
+ Approach
+ </p>
+ </th>
+<th>
+ <p>
+ File
+ </p>
+ </th>
+</tr></thead>
 <tbody>
-<tr><td>
+<tr>
+<td>
               <p>
- <span class="inlinemediaobject"><img src="../../../example/profile_legend.png" width="1170" alt="profile_legend"></span>
+ <span class="inlinemediaobject"><img src="../../../example/profile_legend_local_function.png" alt="profile_legend_local_function"></span>
               </p>
- </td></tr>
-<tr><td>
+ </td>
+<td>
               <p>
- The local function was called <code class="literal">1e8</code> times to add
- together all the elements of a vector and the run-time was measured
- using Boost.Chrono
- averaging over <code class="literal">10</code> executions of the vector summation
- (see source files profile_boost_local.cpp,
- profile_boost_local_inline.cpp,
- profile_local_functor.cpp,
- profile_global_functor.cpp,
- profile_0x_lambda.cpp,
- profile_boost_lambda.cpp,
- and profile_boost_phoenix.cpp).
+ Boost.LocalFunction
               </p>
- </td></tr>
-<tr><td>
+ </td>
+<td>
               <p>
- The following commands were executed from the library example directory
- to measure compile-time, binary size, and run-time respectively:
-</p>
-<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="special">&gt;</span> <span class="identifier">python</span> <span class="identifier">chrono</span><span class="special">.</span><span class="identifier">py</span> <span class="identifier">bjam</span> <span class="special">{</span><span class="identifier">release</span><span class="special">|</span><span class="identifier">debug</span><span class="special">}</span> <span class="special">&lt;</span><span class="identifier">PROGRAM</span><span class="special">&gt;</span> <span class="preprocessor"># compile</span><span class="special">-</span><span class="identifier">time</span>
-<span class="special">&gt;</span> <span class="identifier">size</span> <span class="special">&lt;</span><span class="identifier">PROGRAM</span><span class="special">&gt;</span> <span class="preprocessor"># binary</span> <span class="identifier">size</span> <span class="special">(</span><span class="identifier">Linux</span> <span class="keyword">and</span> <span class="identifier">Gygwin</span><span class="special">)</span>
-<span class="special">&gt;</span> <span class="special">&lt;</span><span class="identifier">PROGRAM</span><span class="special">&gt;</span> <span class="preprocessor"># run</span><span class="special">-</span><span class="identifier">time</span>
-</pre>
-<p>
+ profile_local_function.cpp
               </p>
- </td></tr>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <span class="inlinemediaobject"><img src="../../../example/profile_legend_local_function_inline.png" alt="profile_legend_local_function_inline"></span>
+ </p>
+ </td>
+<td>
+ <p>
+ Boost.LocalFunction
+ inline
+ </p>
+ </td>
+<td>
+ <p>
+ profile_local_function_inline.cpp
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <span class="inlinemediaobject"><img src="../../../example/profile_legend_lambda.png" alt="profile_legend_lambda"></span>
+ </p>
+ </td>
+<td>
+ <p>
+ C++11
+ Lambda Function
+ </p>
+ </td>
+<td>
+ <p>
+ profile_lambda.cpp
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <span class="inlinemediaobject"><img src="../../../example/profile_legend_local_functor.png" alt="profile_legend_local_functor"></span>
+ </p>
+ </td>
+<td>
+ <p>
+ Local Functor
+ </p>
+ </td>
+<td>
+ <p>
+ profile_local_functor.cpp
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <span class="inlinemediaobject"><img src="../../../example/profile_legend_global_functor.png" alt="profile_legend_global_functor"></span>
+ </p>
+ </td>
+<td>
+ <p>
+ Global Functor
+ </p>
+ </td>
+<td>
+ <p>
+ profile_global_functor.cpp
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <span class="inlinemediaobject"><img src="../../../example/profile_legend_phoenix.png" alt="profile_legend_phoenix"></span>
+ </p>
+ </td>
+<td>
+ <p>
+ Boost.Phoenix
+ </p>
+ </td>
+<td>
+ <p>
+ profile_phoenix.cpp
+ </p>
+ </td>
+</tr>
 </tbody>
 </table></div>
 <div class="informaltable"><table class="table">
 <colgroup><col></colgroup>
 <thead><tr><th>
               <p>
- GCC 4.5.1 With C++11
- Lambdas and "Local Types as Template Parameters" (<code class="literal">bjam
- cxxflags=-std=c++0x ...</code>) on Ubuntu Linux 10
+ GCC 4.5.3 With C++11 Lambdas and "Local Types as Template Parameters"
+ (<code class="literal">bjam cxxflags=-std=c++0x ...</code>)
               </p>
             </th></tr></thead>
 <tbody>
@@ -658,14 +954,14 @@
               <p>
                 <span class="bold"><strong>Compiled with <code class="literal">bjam release ...</code>
                 for maximum optimization (<code class="literal">-O3 -finline-functions</code>)</strong></span>
- <span class="inlinemediaobject"><img src="../../../example/profile_gcc-4.5.1-0x_release.png" width="1170" alt="profile_gcc-4.5.1-0x_release"></span>
+ <span class="inlinemediaobject"><img src="../../../example/profile_gcc_cpp11_release.png" width="1170" alt="profile_gcc_cpp11_release"></span>
               </p>
             </td></tr>
 <tr><td>
               <p>
                 <span class="bold"><strong>Compiled with <code class="literal">bjam debug ...</code>
                 for no optimization (<code class="literal">-O0 -fno-inline</code>)</strong></span>
- <span class="inlinemediaobject"><img src="../../../example/profile_gcc-4.5.1-0x_debug.png" width="1170" alt="profile_gcc-4.5.1-0x_debug"></span>
+ <span class="inlinemediaobject"><img src="../../../example/profile_gcc_cpp11_debug.png" width="1170" alt="profile_gcc_cpp11_debug"></span>
               </p>
             </td></tr>
 </tbody>
@@ -676,7 +972,7 @@
               <p>
                 MSVC 8.0 With "Local Types as Template Parameters" (Without
                 <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a>
- Lambdas) on Windows XP
+ Lambdas)
               </p>
             </th></tr></thead>
 <tbody>
@@ -684,13 +980,13 @@
               <p>
                 <span class="bold"><strong>Compiled with <code class="literal">bjam release ...</code>
                 for maximum optimization (<code class="literal">/O2 /Ob2</code>)</strong></span>
- <span class="inlinemediaobject"><img src="../../../example/profile_msvc-8.0_release.png" width="1170" alt="profile_msvc-8.0_release"></span>
+ <span class="inlinemediaobject"><img src="../../../example/profile_msvc_release.png" width="1170" alt="profile_msvc_release"></span>
               </p>
             </td></tr>
 <tr><td>
               <p>
                 <span class="bold"><strong>Compiled with <code class="literal">bjam debug ...</code>
- for no optimization (<code class="literal">/Od /Ob0</code>)</strong></span> <span class="inlinemediaobject"><img src="../../../example/profile_msvc-8.0_debug.png" width="1170" alt="profile_msvc-8.0_debug"></span>
+ for no optimization (<code class="literal">/Od /Ob0</code>)</strong></span> <span class="inlinemediaobject"><img src="../../../example/profile_msvc_debug.png" width="1170" alt="profile_msvc_debug"></span>
               </p>
             </td></tr>
 </tbody>
@@ -701,8 +997,7 @@
               <p>
                 GCC 4.3.4 With C++03
                 Only (Without C++11
- Lambdas and Without "Local Types as Template Parameters) on
- Cygwin
+ Lambdas and Without "Local Types as Template Parameters")
               </p>
             </th></tr></thead>
 <tbody>
@@ -710,14 +1005,14 @@
               <p>
                 <span class="bold"><strong>Compiled with <code class="literal">bjam release ...</code>
                 for maximum optimization (<code class="literal">-O3 -finline-functions</code>)</strong></span>
- <span class="inlinemediaobject"><img src="../../../example/profile_gcc-4.3.4_release.png" width="1170" alt="profile_gcc-4.3.4_release"></span>
+ <span class="inlinemediaobject"><img src="../../../example/profile_gcc_release.png" width="1170" alt="profile_gcc_release"></span>
               </p>
             </td></tr>
 <tr><td>
               <p>
                 <span class="bold"><strong>Compiled with <code class="literal">bjam debug ...</code>
                 for no optimization (<code class="literal">-O0 -fno-inline</code>)</strong></span>
- <span class="inlinemediaobject"><img src="../../../example/profile_gcc-4.3.4_debug.png" width="1170" alt="profile_gcc-4.3.4_debug"></span>
+ <span class="inlinemediaobject"><img src="../../../example/profile_gcc_debug.png" width="1170" alt="profile_gcc_debug"></span>
               </p>
             </td></tr>
 </tbody>

Modified: sandbox/local_function/libs/local_function/doc/html/index.html
==============================================================================
--- sandbox/local_function/libs/local_function/doc/html/index.html (original)
+++ sandbox/local_function/libs/local_function/doc/html/index.html 2012-01-26 17:21:08 EST (Thu, 26 Jan 2012)
@@ -222,7 +222,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: January 23, 2012 at 10:04:24 GMT</small></p></td>
+<td align="left"><p><small>Last revised: January 26, 2012 at 22:13:12 GMT</small></p></td>
 <td align="right"><div class="copyright-footer"></div></td>
 </tr></table>
 <hr>

Modified: sandbox/local_function/libs/local_function/doc/local_function.qbk
==============================================================================
--- sandbox/local_function/libs/local_function/doc/local_function.qbk (original)
+++ sandbox/local_function/libs/local_function/doc/local_function.qbk 2012-01-26 17:21:08 EST (Thu, 26 Jan 2012)
@@ -91,8 +91,15 @@
 [import ../example/gcc_lambda_cpp11.cpp]
 [import ../example/scope_exit.cpp]
 [import ../example/scope_exit.hpp]
-[import ../example/boost_phoenix_local_factorial.cpp]
-[import ../example/boost_phoenix_factorial.cpp]
+[import ../example/phoenix_local_factorial.cpp]
+[import ../example/phoenix_factorial.cpp]
+[import ../example/noncopyable_lambda.cpp]
+[import ../example/noncopyable_local_function.cpp]
+[import ../example/expensive_copy_lambda.cpp]
+[import ../example/expensive_copy_local_function.cpp]
+[import ../example/add_local_functor.cpp]
+[import ../example/add_global_functor.cpp]
+[import ../example/add_phoenix.cpp]
 [import ../example/impl_tparam_tricks.cpp]
 [import ../example/impl_pp_keyword.cpp]
 [import ../example/impl_factorial.cpp]

Modified: sandbox/local_function/libs/local_function/test/Jamfile.v2
==============================================================================
--- sandbox/local_function/libs/local_function/test/Jamfile.v2 (original)
+++ sandbox/local_function/libs/local_function/test/Jamfile.v2 2012-01-26 17:21:08 EST (Thu, 26 Jan 2012)
@@ -1,9 +1,7 @@
 
 import testing ;
 
-project : requirements
- <library>/boost//unit_test_framework
-;
+project : requirements <library>/boost//unit_test_framework ;
 
 run add.cpp ;
 run add_classifiers.cpp ;


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