summaryrefslogtreecommitdiff
path: root/libs/local_function
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-06-25 22:59:01 +0000
committer <>2013-09-27 11:49:28 +0000
commit8c4528713d907ee2cfd3bfcbbad272c749867f84 (patch)
treec09e2ce80f47b90c85cc720f5139089ad9c8cfff /libs/local_function
downloadboost-tarball-8c4528713d907ee2cfd3bfcbbad272c749867f84.tar.gz
Imported from /home/lorry/working-area/delta_boost-tarball/boost_1_54_0.tar.bz2.boost_1_54_0baserock/morph
Diffstat (limited to 'libs/local_function')
-rw-r--r--libs/local_function/doc/Jamfile.v251
-rw-r--r--libs/local_function/doc/acknowledgements.qbk35
-rw-r--r--libs/local_function/doc/advanced_topics.qbk495
-rw-r--r--libs/local_function/doc/alternatives.qbk262
-rw-r--r--libs/local_function/doc/bibliography.qbk23
-rw-r--r--libs/local_function/doc/examples.qbk190
-rw-r--r--libs/local_function/doc/getting_started.qbk73
-rw-r--r--libs/local_function/doc/html/BOOST_LOCAL_FUNCTION.html103
-rw-r--r--libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html56
-rw-r--r--libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html56
-rw-r--r--libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html66
-rw-r--r--libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_ID.html77
-rw-r--r--libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_ID_TPL.html77
-rw-r--r--libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_NAME.html90
-rw-r--r--libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_NAME_TPL.html65
-rw-r--r--libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TPL.html66
-rw-r--r--libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TYPEOF.html78
-rw-r--r--libs/local_function/doc/html/boost_localfunction/acknowledgments.html102
-rw-r--r--libs/local_function/doc/html/boost_localfunction/advanced_topics.html1410
-rw-r--r--libs/local_function/doc/html/boost_localfunction/alternatives.html1070
-rw-r--r--libs/local_function/doc/html/boost_localfunction/bibliography.html74
-rw-r--r--libs/local_function/doc/html/boost_localfunction/examples.html710
-rw-r--r--libs/local_function/doc/html/boost_localfunction/getting_started.html192
-rw-r--r--libs/local_function/doc/html/boost_localfunction/implementation.html230
-rw-r--r--libs/local_function/doc/html/boost_localfunction/no_variadic_macros.html265
-rw-r--r--libs/local_function/doc/html/boost_localfunction/release_notes.html168
-rw-r--r--libs/local_function/doc/html/boost_localfunction/tutorial.html540
-rw-r--r--libs/local_function/doc/html/index.html235
-rw-r--r--libs/local_function/doc/html/reference.html71
-rw-r--r--libs/local_function/doc/implementation.qbk50
-rw-r--r--libs/local_function/doc/introduction.qbk40
-rw-r--r--libs/local_function/doc/local_function.qbk126
-rw-r--r--libs/local_function/doc/no_variadic_macros.qbk68
-rw-r--r--libs/local_function/doc/release_notes.qbk54
-rw-r--r--libs/local_function/doc/tutorial.qbk225
-rw-r--r--libs/local_function/example/Jamfile.v277
-rw-r--r--libs/local_function/example/add_cxx11_lambda.cpp34
-rw-r--r--libs/local_function/example/add_global_functor.cpp38
-rw-r--r--libs/local_function/example/add_local_functor.cpp35
-rw-r--r--libs/local_function/example/add_phoenix.cpp34
-rwxr-xr-xlibs/local_function/example/chrono.py25
-rw-r--r--libs/local_function/example/const_block.cpp18
-rw-r--r--libs/local_function/example/const_block.hpp58
-rw-r--r--libs/local_function/example/const_block_error.cpp20
-rw-r--r--libs/local_function/example/const_block_error_cxx11_lambda.cpp28
-rw-r--r--libs/local_function/example/expensive_copy_cxx11_lambda.cpp39
-rw-r--r--libs/local_function/example/expensive_copy_local_function.cpp35
-rw-r--r--libs/local_function/example/gcc_access.cpp23
-rw-r--r--libs/local_function/example/gcc_cxx11_lambda.cpp35
-rw-r--r--libs/local_function/example/gcc_lambda.cpp36
-rw-r--r--libs/local_function/example/gcc_lambda.hpp129
-rw-r--r--libs/local_function/example/gcc_square.cpp23
-rw-r--r--libs/local_function/example/gcc_store.cpp33
-rw-r--r--libs/local_function/example/impl_pp_keyword.cpp28
-rw-r--r--libs/local_function/example/impl_tparam_tricks.cpp71
-rw-r--r--libs/local_function/example/n2529_this.cpp47
-rw-r--r--libs/local_function/example/n2550_find_if.cpp44
-rw-r--r--libs/local_function/example/noncopyable_cxx11_lambda_error.cpp36
-rw-r--r--libs/local_function/example/noncopyable_local_function.cpp32
-rw-r--r--libs/local_function/example/phoenix_factorial.cpp40
-rw-r--r--libs/local_function/example/phoenix_factorial_local.cpp31
-rw-r--r--libs/local_function/example/profile.xlsbin0 -> 181248 bytes
-rw-r--r--libs/local_function/example/profile_cxx11_lambda.cpp44
-rw-r--r--libs/local_function/example/profile_gcc_cxx11_debug.pngbin0 -> 52012 bytes
-rw-r--r--libs/local_function/example/profile_gcc_cxx11_release.pngbin0 -> 54872 bytes
-rw-r--r--libs/local_function/example/profile_gcc_debug.pngbin0 -> 44726 bytes
-rw-r--r--libs/local_function/example/profile_gcc_release.pngbin0 -> 48328 bytes
-rw-r--r--libs/local_function/example/profile_global_functor.cpp51
-rw-r--r--libs/local_function/example/profile_helpers.hpp54
-rw-r--r--libs/local_function/example/profile_legend_cxx11_lambda.pngbin0 -> 207 bytes
-rw-r--r--libs/local_function/example/profile_legend_global_functor.pngbin0 -> 205 bytes
-rw-r--r--libs/local_function/example/profile_legend_local_function.pngbin0 -> 206 bytes
-rw-r--r--libs/local_function/example/profile_legend_local_function_inline.pngbin0 -> 206 bytes
-rw-r--r--libs/local_function/example/profile_legend_local_functor.pngbin0 -> 205 bytes
-rw-r--r--libs/local_function/example/profile_legend_phoenix.pngbin0 -> 207 bytes
-rw-r--r--libs/local_function/example/profile_local_function.cpp45
-rw-r--r--libs/local_function/example/profile_local_function_inline.cpp45
-rw-r--r--libs/local_function/example/profile_local_functor.cpp50
-rw-r--r--libs/local_function/example/profile_msvc_debug.pngbin0 -> 43851 bytes
-rw-r--r--libs/local_function/example/profile_msvc_release.pngbin0 -> 50420 bytes
-rw-r--r--libs/local_function/example/profile_phoenix.cpp45
-rw-r--r--libs/local_function/example/scope_exit.cpp110
-rw-r--r--libs/local_function/example/scope_exit.hpp51
-rw-r--r--libs/local_function/index.html15
-rw-r--r--libs/local_function/test/Jamfile.v251
-rw-r--r--libs/local_function/test/add.cpp35
-rw-r--r--libs/local_function/test/add_classifiers.cpp30
-rw-r--r--libs/local_function/test/add_classifiers_seq.cpp26
-rw-r--r--libs/local_function/test/add_classifiers_seq_nova.cpp10
-rw-r--r--libs/local_function/test/add_default.cpp28
-rw-r--r--libs/local_function/test/add_default_seq.cpp19
-rw-r--r--libs/local_function/test/add_default_seq_nova.cpp10
-rw-r--r--libs/local_function/test/add_except.cpp34
-rw-r--r--libs/local_function/test/add_except_seq.cpp25
-rw-r--r--libs/local_function/test/add_except_seq_nova.cpp10
-rw-r--r--libs/local_function/test/add_inline.cpp37
-rw-r--r--libs/local_function/test/add_inline_seq.cpp28
-rw-r--r--libs/local_function/test/add_inline_seq_nova.cpp10
-rw-r--r--libs/local_function/test/add_params_only.cpp28
-rw-r--r--libs/local_function/test/add_params_only_seq.cpp19
-rw-r--r--libs/local_function/test/add_params_only_seq_nova.cpp10
-rw-r--r--libs/local_function/test/add_seq.cpp28
-rw-r--r--libs/local_function/test/add_seq_nova.cpp10
-rw-r--r--libs/local_function/test/add_template.cpp41
-rw-r--r--libs/local_function/test/add_template_seq.cpp31
-rw-r--r--libs/local_function/test/add_template_seq_nova.cpp10
-rw-r--r--libs/local_function/test/add_this.cpp51
-rw-r--r--libs/local_function/test/add_this_seq.cpp43
-rw-r--r--libs/local_function/test/add_this_seq_nova.cpp10
-rw-r--r--libs/local_function/test/add_typed.cpp47
-rw-r--r--libs/local_function/test/add_typed_seq.cpp37
-rw-r--r--libs/local_function/test/add_typed_seq_nova.cpp10
-rw-r--r--libs/local_function/test/add_with_default.cpp32
-rw-r--r--libs/local_function/test/add_with_default_seq.cpp21
-rw-r--r--libs/local_function/test/add_with_default_seq_nova.cpp10
-rw-r--r--libs/local_function/test/addable.hpp26
-rw-r--r--libs/local_function/test/all_decl.cpp177
-rw-r--r--libs/local_function/test/all_decl_seq.cpp170
-rw-r--r--libs/local_function/test/all_decl_seq_nova.cpp10
-rw-r--r--libs/local_function/test/factorial.cpp57
-rw-r--r--libs/local_function/test/factorial_seq.cpp48
-rw-r--r--libs/local_function/test/factorial_seq_nova.cpp10
-rw-r--r--libs/local_function/test/goto.cpp34
-rw-r--r--libs/local_function/test/goto_error.cpp36
-rw-r--r--libs/local_function/test/goto_error_seq.cpp27
-rw-r--r--libs/local_function/test/goto_error_seq_nova.cpp10
-rw-r--r--libs/local_function/test/goto_seq.cpp25
-rw-r--r--libs/local_function/test/goto_seq_nova.cpp10
-rw-r--r--libs/local_function/test/macro_commas.cpp52
-rw-r--r--libs/local_function/test/macro_commas_seq.cpp44
-rw-r--r--libs/local_function/test/macro_commas_seq_nova.cpp10
-rw-r--r--libs/local_function/test/nesting.cpp37
-rw-r--r--libs/local_function/test/nesting_seq.cpp28
-rw-r--r--libs/local_function/test/nesting_seq_nova.cpp10
-rw-r--r--libs/local_function/test/nova.hpp21
-rw-r--r--libs/local_function/test/operator.cpp38
-rw-r--r--libs/local_function/test/operator_error.cpp38
-rw-r--r--libs/local_function/test/operator_error_seq.cpp29
-rw-r--r--libs/local_function/test/operator_error_seq_nova.cpp10
-rw-r--r--libs/local_function/test/operator_seq.cpp29
-rw-r--r--libs/local_function/test/operator_seq_nova.cpp10
-rw-r--r--libs/local_function/test/overload.cpp52
-rw-r--r--libs/local_function/test/overload_seq.cpp42
-rw-r--r--libs/local_function/test/overload_seq_nova.cpp10
-rw-r--r--libs/local_function/test/return_assign.cpp49
-rw-r--r--libs/local_function/test/return_assign_seq.cpp40
-rw-r--r--libs/local_function/test/return_assign_seq_nova.cpp10
-rw-r--r--libs/local_function/test/return_derivative.cpp41
-rw-r--r--libs/local_function/test/return_derivative_seq.cpp34
-rw-r--r--libs/local_function/test/return_derivative_seq_nova.cpp10
-rw-r--r--libs/local_function/test/return_inc.cpp38
-rw-r--r--libs/local_function/test/return_inc_seq.cpp31
-rw-r--r--libs/local_function/test/return_inc_seq_nova.cpp10
-rw-r--r--libs/local_function/test/return_setget.cpp47
-rw-r--r--libs/local_function/test/return_setget_seq.cpp39
-rw-r--r--libs/local_function/test/return_setget_seq_nova.cpp10
-rw-r--r--libs/local_function/test/return_this.cpp50
-rw-r--r--libs/local_function/test/return_this_seq.cpp43
-rw-r--r--libs/local_function/test/return_this_seq_nova.cpp10
-rw-r--r--libs/local_function/test/same_line.cpp57
-rw-r--r--libs/local_function/test/same_line_seq.cpp48
-rw-r--r--libs/local_function/test/same_line_seq_nova.cpp10
-rw-r--r--libs/local_function/test/ten_void.cpp21
-rw-r--r--libs/local_function/test/ten_void_nova.cpp10
-rw-r--r--libs/local_function/test/transform.cpp47
-rw-r--r--libs/local_function/test/transform_seq.cpp39
-rw-r--r--libs/local_function/test/transform_seq_nova.cpp10
-rw-r--r--libs/local_function/test/typeof.cpp41
-rw-r--r--libs/local_function/test/typeof_seq.cpp30
-rw-r--r--libs/local_function/test/typeof_seq_nova.cpp10
-rw-r--r--libs/local_function/test/typeof_template.cpp43
-rw-r--r--libs/local_function/test/typeof_template_seq.cpp33
-rw-r--r--libs/local_function/test/typeof_template_seq_nova.cpp10
173 files changed, 11814 insertions, 0 deletions
diff --git a/libs/local_function/doc/Jamfile.v2 b/libs/local_function/doc/Jamfile.v2
new file mode 100644
index 000000000..b337944f1
--- /dev/null
+++ b/libs/local_function/doc/Jamfile.v2
@@ -0,0 +1,51 @@
+
+# Copyright (C) 2009-2012 Lorenzo Caminiti
+# Distributed under the Boost Software License, Version 1.0
+# (see accompanying file LICENSE_1_0.txt or a copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+# Home at http://www.boost.org/libs/local_function
+
+import quickbook ;
+using boostbook ;
+
+path-constant images_location : html ;
+path-constant here : . ;
+
+doxygen reference
+ : ../../../boost/local_function.hpp
+ ../../../boost/local_function/config.hpp
+ : <reftitle>"Reference"
+ <doxygen:param>PREDEFINED="DOXYGEN"
+ <doxygen:param>QUIET=YES
+ <doxygen:param>WARN_IF_UNDOCUMENTED=NO
+ <doxygen:param>HIDE_UNDOC_MEMBERS=YES
+ <doxygen:param>HIDE_UNDOC_CLASSES=YES
+ <doxygen:param>ALIASES=" Params=\"<b>Parameters:</b> <table border="0">\" Param{2}=\"<tr><td><b><tt>\\1</tt></b></td><td>\\2</td></tr>\" EndParams=\"</table>\" Returns=\"<b>Returns:</b>\" Note=\"<b>Note:</b>\" Warning=\"<b>Warning:</b>\" See=\"<b>See:</b>\" RefSect{2}=\"\\xmlonly<link linkend='boost_localfunction.\\1'>\\2</link>\\endxmlonly\" RefClass{1}=\"\\xmlonly<computeroutput><classname alt='\\1'>\\1</classname></computeroutput>\\endxmlonly\" RefFunc{1}=\"\\xmlonly<computeroutput><functionname alt='\\1'>\\1</functionname></computeroutput>\\endxmlonly\" RefMacro{1}=\"\\xmlonly<computeroutput><macroname alt='\\1'>\\1</macroname></computeroutput>\\endxmlonly\" "
+ ;
+
+xml qbk : local_function.qbk
+ : <dependency>introduction.qbk
+ <dependency>getting_started.qbk
+ <dependency>tutorial.qbk
+ <dependency>advanced_topics.qbk
+ <dependency>examples.qbk
+ <dependency>reference
+ <dependency>alternatives.qbk
+ <dependency>no_variadic_macros.qbk
+ <dependency>implementation.qbk
+ <dependency>release_notes.qbk
+ <dependency>bibliography.qbk
+ <dependency>acknowledgements.qbk
+ ;
+
+boostbook doc : qbk
+ : <xsl:param>boost.root=../../../..
+ <xsl:param>boost.defaults=Boost
+ <format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/libs/local_function/doc/html
+ <format>pdf:<xsl:param>admon.graphics.extension=".svg"
+ <format>pdf:<xsl:param>img.src.path=$(images_location)/
+ <format>pdf:<xsl:param>draft.mode="no"
+ ;
+
+install pdfinstall : doc/<format>pdf : <location>. <install-type>PDF <name>local_function.pdf ;
+explicit pdfinstall ;
diff --git a/libs/local_function/doc/acknowledgements.qbk b/libs/local_function/doc/acknowledgements.qbk
new file mode 100644
index 000000000..5f1d57177
--- /dev/null
+++ b/libs/local_function/doc/acknowledgements.qbk
@@ -0,0 +1,35 @@
+
+[/ Copyright (C) 2009-2012 Lorenzo Caminiti ]
+[/ Distributed under the Boost Software License, Version 1.0 ]
+[/ (see accompanying file LICENSE_1_0.txt or a copy at ]
+[/ http://www.boost.org/LICENSE_1_0.txt) ]
+[/ Home at http://www.boost.org/libs/local_function ]
+
+[section Acknowledgments]
+
+This section aims to recognize the contributions of /all/ the different people that participated directly or indirectly to the design and development of this library.
+
+Many thanks to Steven Watanabe and Vicente Botet for suggesting to me to use __Boost_ScopeExit__ binding to [@http://lists.boost.org/Archives/boost/2010/04/165149.php emulate local functions].
+Many thanks to Alexander Nasonov for clarifying how __Boost_ScopeExit__ binding could be used to implement local functions and for some [@http://thread.gmane.org/gmane.comp.lib.boost.devel/168612 early work] in this direction.
+
+Many thanks to Gregory Crosswhite for using an early version of this library in [@https://github.com/gcross/CodeSearch one of his projects].
+
+Thanks to David Abrahams, Vicente Botet, et al. for suggesting to provide the [@http://lists.boost.org/Archives/boost/2011/02/176712.php variadic macro syntax] on compilers that support variadic macros.
+
+Thanks to Pierre Morcello for sharing some code that experimented with implementing local functions using __Boost_ScopeExit__ binding (even if this library is not based on such a code).
+
+Thanks to John Bytheway for checking the authors' virtual functor technique that originally allowed this library to pass local functions as template parameters.
+
+Thanks to Jeffrey Lee Hellrung for suggesting the use of the "keyword" `bind` to bind variables in scope and for suggesting to use [^bind(/type/)] to optionally specify the bound variable type.
+Thanks to Vicente Botet for suggesting to provide a macro to expose the bound variable type to the public API.
+
+Thanks to Steven Watanabe, Vicente Botet, Michael Caisse, Yechezkel Mett, Joel de Guzman, Thomas Heller, et al. for helping with the __Alternatives__ section and with the profiling of the different alternatives.
+
+Many thanks to Jeffrey Lee Hellrung for managing the [@http://lists.boost.org/boost-announce/2011/12/0340.php Boost review] of this library.
+Thanks also to all the people that submitted a Boost review: Andrzej Krzemienski, Edward Diener, Gregory Crosswhite, John Bytheway, Hartmut Kaiser, Krzysztof Czainski, Nat Lindon, Pierre Morcello, Thomas Heller, and Vicente J. Botet.
+Thanks to everyone that commented on the library during its Boost review.
+
+Finally, many thanks to the entire __Boost__ community and [@http://lists.boost.org mailing list] for providing valuable comments about this library and great insights on the C++ programming language.
+
+[endsect]
+
diff --git a/libs/local_function/doc/advanced_topics.qbk b/libs/local_function/doc/advanced_topics.qbk
new file mode 100644
index 000000000..2998de6bc
--- /dev/null
+++ b/libs/local_function/doc/advanced_topics.qbk
@@ -0,0 +1,495 @@
+
+[/ Copyright (C) 2009-2012 Lorenzo Caminiti ]
+[/ Distributed under the Boost Software License, Version 1.0 ]
+[/ (see accompanying file LICENSE_1_0.txt or a copy at ]
+[/ http://www.boost.org/LICENSE_1_0.txt) ]
+[/ Home at http://www.boost.org/libs/local_function ]
+
+[section Advanced Topics]
+
+This section illustrates advanced usage of this library.
+At the bottom there is also a list of known limitations of this library.
+
+[section Default Parameters]
+
+This library allows to specify default values for the local function parameters.
+However, the usual C++ syntax for default parameters that uses the assignment symbol `=` cannot be used.
+[footnote
+*Rationale.*
+The assignment symbol `=` cannot be used to specify default parameter values because default values are not part of the parameter type so they cannot be handled using template meta-programming.
+Default parameter values need to be separated from the rest of the parameter declaration using the preprocessor.
+Specifically, this library needs to use preprocessor meta-programming to remove default values when constructing the local function type and also to count the number of default values to provide the correct set of call operators for the local functor.
+Therefore, the symbol `=` cannot be used because it cannot be handled by preprocessor meta-programming (non-alphanumeric symbols cannot be detected by preprocessor meta-programming because they cannot be concatenated by the preprocessor).
+]
+The keyword `default` is used instead:
+
+ ``[^/parameter-type parameter-name/]``, default`` [^/parameter-default-value/]``, ...
+
+For example, let's program a local function `add(x, y)` where the second parameter `y` is optional and has a default value of `2` (see also [@../../test/add_default.cpp =add_default.cpp=]):
+
+[add_default]
+
+Programmers can define a `WITH_DEFAULT` macro similar to the following if they think it improves readability over the above syntax (see also [@../../test/add_with_default.cpp =add_with_default.cpp=]):
+[footnote
+The authors do not personally find the use of the `WITH_DEFAULT` macro more readable and they prefer to use the `default` keyword directly.
+Furthermore, `WITH_DEFAULT` needs to be defined differently for compilers without variadic macros `#define WITH_DEFAULT (default)` so it can only be defined by programmers based on the syntax they decide to use (see the __No_Variadic_Macros__ section).
+]
+
+[add_with_default_macro]
+[add_with_default]
+
+[endsect]
+
+[section Commas and Symbols in Macros]
+
+The C++ preprocessor does not allow commas `,` within macro parameters unless they are wrapped by round parenthesis `()` (see the __Boost_Utility_IdentityType__ documentation for details).
+Therefore, using commas within local function parameters and bindings will generate (cryptic) preprocessor errors unless they are wrapped with an extra set of round parenthesis `()` as explained here.
+
+[note
+Also macro parameters with commas wrapped by angular parenthesis `<>` (templates, etc) or square parenthesis `[]` (multidimensional array access, etc) need to be wrapped by the extra round parenthesis `()` as explained here (this is because the preprocessor only recognizes the round parenthesis and it does not recognize angular, square, or any other type of parenthesis).
+However, macro parameters with commas which are already wrapped by round parenthesis `()` are fine (function calls, some value expressions, etc).
+]
+
+In addition, local function parameter types cannot start with non-alphanumeric symbols (alphanumeric symbols are `A-Z`, `a-z`, and `0-9`).
+[footnote
+*Rationale.*
+This limitation is because this library uses preprocessor token concatenation [^##] to inspect the macro parameters (to distinguish between function parameters, bound variables, etc) and the C++ preprocessor does not allow to concatenate non-alphanumeric tokens.
+]
+The library will generate (cryptic) preprocessor errors if a parameter type starts with a non-alphanumeric symbol.
+
+Let's consider the following example:
+
+ void BOOST_LOCAL_FUNCTION(
+ const std::map<std::string, size_t>& m, // (1) Error.
+ ::sign_t sign, // (2) Error.
+ const size_t& factor,
+ default key_sizeof<std::string, size_t>::value, // (3) Error.
+ const std::string& separator, default cat(":", " ") // (4) OK.
+ ) {
+ ...
+ } BOOST_LOCAL_FUNCTION_NAME(f)
+
+[*(1)] The parameter type `const std::map<std::string, size_t>&` contains a comma `,` after the first template parameter `std::string`.
+This comma is not wrapped by any round parenthesis `()` thus it will cause a preprocessor error.
+[footnote
+The preprocessor always interprets unwrapped commas as separating macro parameters.
+Thus in this case the comma will indicate to the preprocessor that the first macro parameter is `const std::map<std::tring`, the second macro parameter is `size_t>& m`, etc instead of passing `const std::map<std::string, size_t>& m` as a single macro parameter.
+]
+The __Boost_Utility_IdentityType__ macro `BOOST_IDENTITY_TYPE((`[^['type-with-commas]]`))` defined in the =boost/utility/identity_type.hpp= header can be used to wrap a type within extra parenthesis `()` so to overcome this problem:
+
+ #include <boost/utility/identity_type.hpp>
+
+ void BOOST_LOCAL_FUNCTION(
+ BOOST_IDENTITY_TYPE((const std::map<std::string, size_t>&)) m, // OK.
+ ...
+ ) {
+ ...
+ } BOOST_LOCAL_FUNCTION_NAME(f)
+
+This macro expands to an expression that evaluates (at compile-time) exactly to the specified type (furthermore, this macro does not use variadic macros so it works on any __CXX03__ compiler).
+Note that a total of two set of parenthesis `()` are needed: The parenthesis to invoke the `BOOST_IDENTITY_TYPE(...)` macro plus the parenthesis to wrap the type expression (and therefore any comma `,` that it contains) passed as parameter to the `BOOST_IDENTITY_TYPE((...))` macro.
+Finally, the `BOOST_IDENTITY_TYPE` macro must be prefixed by the `typename` keyword `typename BOOST_IDENTITY_TYPE(`[^['parenthesized-type]]`)` when used together with the [macroref BOOST_LOCAL_FUNCTION_TPL] macro within templates.
+
+[note
+Often, there might be better ways to overcome this limitation that lead to code which is more readable than the one using the `BOOST_IDENTITY_TYPE` macro.
+]
+
+For example, in this case a `typedef` from the enclosing scope could have been used to obtain the following valid and perhaps more readable code:
+
+ typedef std::map<std::string, size_t> map_type;
+ void BOOST_LOCAL_FUNCTION(
+ const map_type& m, // OK (and more readable).
+ ...
+ ) BOOST_LOCAL_FUNCTION_NAME(f)
+
+[*(2)] The parameter type `::sign_t` starts with the non-alphanumeric symbols `::` thus it will generate preprocessor errors if used as a local function parameter type.
+The `BOOST_IDENTITY_TYPE` macro can also be used to overcome this issue:
+
+ void BOOST_LOCAL_FUNCTION(
+ ...
+ BOOST_IDENTITY_TYPE((::sign_t)) sign, // OK.
+ ...
+ ) {
+ ...
+ } BOOST_LOCAL_FUNCTION_NAME(f)
+
+[note
+Often, there might be better ways to overcome this limitation that lead to code which is more readable than the one using the `BOOST_IDENTITY_TYPE` macro.
+]
+
+For example, in this case the symbols `::` could have been simply dropped to obtain the following valid and perhaps more readable code:
+
+ void BOOST_LOCAL_FUNCTION(
+ ...
+ sign_t sign, // OK (and more readable).
+ ...
+ ) {
+ ...
+ } BOOST_LOCAL_FUNCTION_NAME(f)
+
+[*(3)] The default parameter value `key_sizeof<std::string, size_t>::value` contains a comma `,` after the first template parameter `std::string`.
+Again, this comma is not wrapped by any parenthesis `()` so it will cause a preprocessor error.
+Because this is a value expression (and not a type expression), it can simply be wrapped within an extra set of round parenthesis `()`:
+
+ void BOOST_LOCAL_FUNCTION(
+ ...
+ const size_t& factor,
+ default (key_sizeof<std::string, size_t>::value), // OK.
+ ...
+ ) {
+ ...
+ } BOOST_LOCAL_FUNCTION_NAME(f)
+
+[*(4)] The default parameter value `cat(":", " ")` is instead fine because it contains a comma `,` which is already wrapped by the parenthesis `()` of the function call `cat(...)`.
+
+Consider the following complete example (see also [@../../test/macro_commas.cpp =macro_commas.cpp=]):
+
+[macro_commas]
+
+[endsect]
+
+[section Assignments and Returns]
+
+Local functions are function objects so it is possible to assign them to other functors like __Boost_Function__'s `boost::function` in order to store the local function into a variable, pass it as a parameter to another function, or return it from the enclosing function.
+
+For example (see also [@../../test/return_assign.cpp =return_assign.cpp=]):
+
+[return_assign]
+
+[warning
+As with __CXX11_lambda_functions__, programmers are responsible to ensure that bound variables are valid in any scope where the local function object is called.
+Returning and calling a local function outside its declaration scope will lead to undefined behaviour if any of the bound variable is no longer valid in the scope where the local function is called (see the __Examples__ section for more examples on the extra care needed when returning a local function as a closure).
+It is always safe instead to call a local function within its enclosing scope.
+]
+
+In addition, a local function can bind and call other local functions.
+Local functions should always be bound by constant reference `const bind&` to avoid unnecessary copies.
+For example, the following local function `inc_sum` binds the local function `inc` so `inc_sum` can call `inc` (see aslo [@../../test/transform.cpp =transform.cpp=]):
+
+[transform]
+
+[endsect]
+
+[section Nesting]
+
+It is possible to nest local functions into one another.
+For example (see also [@../../test/nesting.cpp =nesting.cpp=]):
+
+[nesting]
+
+[endsect]
+
+[section Accessing Types (concepts, etc)]
+
+This library never requires to explicitly specify the type of bound variables (e.g., this reduces maintenance because the local function declaration and definition do not have to change even if the bound variable types change as long as the semantics of the local function remain valid).
+From within local functions, programmers can access the type of a bound variable using the following macro:
+
+ BOOST_LOCAL_FUNCTION_TYPEOF(``/bound-variable-name/``)
+
+The [macroref BOOST_LOCAL_FUNCTION_TYPEOF] macro expands to a type expression that evaluates (at compile-time) to the fully qualified type of the bound variable with the specified name.
+This type expression is fully qualified in the sense that it will be constant if the variable is bound by constant `const bind[&]` and it will also be a reference if the variable is bound by reference `[const] bind&` (if needed, programmers can remove the `const` and `&` qualifiers using `boost::remove_const` and `boost::remove_reference`, see __Boost_TypeTraits__).
+
+The deduced bound type can be used within the body to check concepts, declare local variables, etc.
+For example (see also [@../../test/typeof.cpp =typeof.cpp=] and [@../../test/addable.hpp =addable.hpp=]):
+
+[typeof]
+
+Within templates, [macroref BOOST_LOCAL_FUNCTION_TYPEOF] should not be prefixed by the `typename` keyword but eventual type manipulations need the `typename` prefix as usual (see also [@../../test/typeof_template.cpp =typeof_template.cpp=] and [@../../test/addable.hpp =addable.hpp=]):
+
+[typeof_template]
+
+In this context, it is best to use the [macroref BOOST_LOCAL_FUNCTION_TYPEOF] macro instead of using __Boost_Typeof__ to reduce the number of times that __Boost_Typeof__ is invoked (either the library already internally used __Boost_Typeof__ once, in which case using this macro will not use __Boost_Typeof__ again, or the bound variable type is explicitly specified by programmers as shown be below, in which case using this macro will not use __Boost_Typeof__ at all).
+
+Furthermore, within the local function body it possible to access the result type using `result_type`, the type of the first parameter using `arg1_type`, the type of the second parameter using `arg2_type`, etc.
+[footnote
+*Rationale.*
+The type names `result_type` and `arg`[^['N]]`_type` follow the __Boost_TypeTraits__ naming conventions for function traits.
+]
+
+[endsect]
+
+[section Specifying Types (no Boost.Typeof)]
+
+While not required, it is possible to explicitly specify the type of bound variables so the library will not internally use __Boost_Typeof__ to automatically deduce the types.
+When specified, the bound variable type must follow the `bind` "keyword" and it must be wrapped within round parenthesis `()`:
+
+ bind(``/variable-type/``) ``/variable-name/`` // Bind by value with explicit type.
+ bind(``/variable-type/``)& ``/variable-name/`` // Bind by reference with explicit type.
+ const bind(``/variable-type/``) ``/variable-name/`` // Bind by constant value with explicit type.
+ const bind(``/variable-type/``)& ``/variable-name/`` // Bind by constant reference with explicit type.
+ bind(``/class-type/``*) this_ // Bind object `this` with explicit type.
+ const bind(``/class-type/``*) this_ // Bind object `this` by constant with explicit type.
+
+Note that within the local function body it is always possible to abstract the access to the type of a bound variable using [macroref BOOST_LOCAL_FUNCTION_TYPEOF] (even when the bound variable type is explicitly specified in the local function declaration).
+
+The library also uses __Boost_Typeof__ to determine the local function result type (because this type is specified outside the [macroref BOOST_LOCAL_FUNCTION] macro).
+Thus it is also possible to specify the local function result type as one of the [macroref BOOST_LOCAL_FUNCTION] macro parameters prefixing it by `return` so the library will not use __Boost_Typeof__ to deduce the result type:
+
+ BOOST_LOCAL_FUNCTION_TYPE(return ``[^/result-type/]``, ...)
+
+Note that the result type must be specified only once either before the macro (without the `return` prefix) or as one of the macro parameters (with the `return` prefix).
+As always, the result type can be `void` to declare a function that returns nothing (so `return void` is allowed when the result type is specified as one of the macro parameters).
+
+The following example specifies all bound variables and result types (see also [@../../test/add_typed.cpp =add_typed.cpp=]):
+[footnote
+In the examples of this documentation, bound variables, function parameters, and the result type are specified in this order because this is the order used by __CXX11_lambda_functions__.
+However, the library accepts bound variables, function parameters, and the result type in any order.
+]
+
+[add_typed]
+
+Unless necessary, it is recommended to not specify the bound variable and result types.
+Let the library deduce these types so the local function syntax will be more concise and the local function declaration will not have to change if a bound variable type changes (reducing maintenance).
+
+[note
+When all bound variable and result types are explicitly specified, the library implementation will not use __Boost_Typeof__.
+]
+
+[endsect]
+
+[section Inlining]
+
+Local functions can be declared [@http://en.wikipedia.org/wiki/Inline_function inline] to increase the chances that the compiler will be able to reduce the run-time of the local function call by inlining the generated assembly code.
+A local function is declared inline by prefixing its name with the keyword `inline`:
+
+ ``/result-type/`` BOOST_LOCAL_FUNCTION(``/parameters/``) {
+ ... // Body.
+ } BOOST_LOCAL_FUNCTION_NAME(inline ``/name/``) // Inlining.
+
+When inlining a local function, note the following:
+
+* On __CXX03__ compliant compilers, inline local functions always have a run-time comparable to their equivalent implementation that uses local functors (see the __Alternatives__ section).
+However, inline local functions have the important limitation that they cannot be assigned to other functors (like `boost::function`) and they cannot be passed as template parameters.
+* On __CXX11__ compilers, `inline` has no effect because this library will automatically generate code that uses __CXX11__ specific features to inline the local function calls whenever possible even if the local function is not declared inline.
+Furthermore, non __CXX11__ local functions can always be passes as template parameters even when they are declared inline.
+[footnote
+*Rationale.*
+This library uses an indirect function call via a function pointer in order to pass the local function as a template parameter (see the __Implementation__ section).
+No compiler has yet been observed to be able to inline function calls when they use such indirect function pointer calls.
+Therefore, inline local functions do not use such indirect function pointer call (so they are more likely to be optimized) but because of that they cannot be passed as template parameters.
+The indirect function pointer call is needed on __CXX03__ but it is not needed on __CXX11__ (see __N2657__ and __Boost_Config__'s `BOOST_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS`) thus this library automatically generates local function calls that can be inline on __CXX11__ compilers (even when the local function is not declared inline).
+]
+
+[important
+It is recommended to not declare a local function inline unless it is strictly necessary for optimizing pure __CXX03__ compliant code (because in all other cases this library will automatically take advantage of __CXX11__ features to optimize the local function calls while always allowing to pass the local function as a template parameter).
+]
+
+For example, the following local function is declared inline (thus a for-loop needs to be used for portability instead of passing the local function as a template parameter to the `std::for_each` algorithm, see also [@../../test/add_inline.cpp =add_inline.cpp=]):
+
+[add_inline]
+
+[endsect]
+
+[section Recursion]
+
+Local functions can be declared [@http://en.wikipedia.org/wiki/Recursion_(computer_science)#Recursive_procedures recursive] so a local function can recursively call itself from its body (as usual with C++ functions).
+A local function is declared recursive by prefixing its name with the `recursive` "keyword" (thus `recursive` cannot be used as a local function name):
+
+ ``/result-type/`` BOOST_LOCAL_FUNCTION(``/parameters/``) {
+ ... // Body.
+ } BOOST_LOCAL_FUNCTION_NAME(recursive ``/name/``) // Recursive.
+
+For example, the following local function is used to recursively calculate the factorials of all the numbers in the specified vector (see also [@../../test/factorial.cpp =factorial.cpp=]):
+
+[factorial]
+
+Compilers have not been observed to be able to inline recursive local function calls not even when the recursive local function is also declared inline:
+
+ ... BOOST_LOCAL_FUNCTION_NAME(inline recursive factorial)
+
+Recursive local functions should never be called outside their declaration scope.
+[footnote
+*Rationale.*
+This limitation comes from the fact that the global functor used to pass the local function as a template parameter (and eventually returned outside the declarations scope) does not know the local function name so the local function name used for recursive call cannot be set in the global functor.
+This limitation together with preventing the possibility for inlining are the reasons why local functions are not recursive unless programmers explicitly declare them `recursive`.
+]
+
+[warning
+If a local function is returned from the enclosing function and called in a different scope, the behaviour is undefined (and it will likely result in a run-time error).
+]
+
+This is not a limitation with respect to __CXX11_lambda_functions__ because lambdas can never call themselves recursively (in other words, there is no recursive lambda function that can successfully be called outside its declaration scope because there is no recursive lambda function at all).
+
+[endsect]
+
+[section Overloading]
+
+Because local functions are functors, it is possible to overload them using the `boost::overloaded_function` functor of __Boost_Functional_OverloadedFunction__ from the =boost/functional/overloaded_function.hpp= header (see the __Boost_Functional_OverloadedFunction__ documentation for details).
+
+In the following example, the overloaded function object `add` can be called with signatures from either the local function `add_s`, or the local function `add_d`, or the local function `add_d` with its extra default parameter, or the function pointer `add_i` (see also [@../../test/overload.cpp =overload.cpp=]):
+
+[overload_decl]
+[overload]
+
+[endsect]
+
+[section Exception Specifications]
+
+It is possible to program exception specifications for local functions by specifying them after the [macroref BOOST_LOCAL_FUNCTION] macro and before the body code block `{ ... }`.
+
+[important
+Note that the exception specifications only apply to the body code specified by programmers and they do not apply to the rest of the code automatically generated by the macro expansions to implement local functions.
+For example, even if the body code is specified to throw no exception using `throw () { ... }`, the execution of the library code automatically generated by the macros could still throw (if there is no memory, etc).
+]
+
+For example (see also [@../../test/add_except.cpp =add_except.cpp=]):
+
+[add_except]
+
+[endsect]
+
+[section Storage Classifiers]
+
+Local function parameters support the storage classifiers as usual in __CXX03__.
+The `auto` storage classifier is specified as:
+[footnote
+The `auto` storage classifier is part of the __CXX03__ standard and therefore supported by this library.
+However, the meaning and usage of the `auto` keyword changed in __CXX11__.
+Therefore, use the `auto` storage classifier with the usual care in order to avoid writing __CXX03__ code that might not work on __CXX11__.
+]
+
+ auto ``/parameter-type parameter-name/``
+
+The `register` storage classifier is specified as:
+
+ register ``/parameter-type parameter-name/``
+
+For example (see also [@../../test/add_classifiers.cpp =add_classifiers.cpp=]):
+
+[add_classifiers]
+
+[endsect]
+
+[section Same Line Expansions]
+
+In general, it is not possible to expand the [macroref BOOST_LOCAL_FUNCTION], [macroref BOOST_LOCAL_FUNCTION_TPL] macros multiple times on the same line.
+[footnote
+*Rationale.*
+The [macroref BOOST_LOCAL_FUNCTION] and [macroref BOOST_LOCAL_FUNCTION_TPL] macros internally use `__LINE__` to generate unique identifiers.
+Therefore, if these macros are expanded more than on time on the same line, the generated identifiers will no longer be unique and the code will not compile.
+(This restriction does not apply to MSVC and other compilers that provide the non-standard `__COUNTER__` macro.)
+Note that the [macroref BOOST_LOCAL_FUNCTION_NAME] macro can always be expanded multiple times on the same line because the unique local function name (and not `__LINE__`) is used by this macro to generate unique identifiers (so there is no need for a `BOOST_LOCAL_FUNCTION_NAME_ID` macro).
+]
+
+Therefore, this library provides additional macros [macroref BOOST_LOCAL_FUNCTION_ID] and [macroref BOOST_LOCAL_FUNCTION_ID_TPL] which can be expanded multiple times on the same line as long as programmers specify unique identifiers as the macros' first parameters.
+The unique identifier can be any token (not just numeric) that can be successfully concatenated by the preprocessor (e.g., `local_function_number_1_at_line_123`).
+[footnote
+Because there are restrictions on the set of tokens that the preprocessor can concatenate and because not all compilers correctly implement these restrictions, it is in general recommended to specify unique identifiers as a combination of alphanumeric tokens.
+]
+
+The [macroref BOOST_LOCAL_FUNCTION_ID] and [macroref BOOST_LOCAL_FUNCTION_ID_TPL] macros accept local function parameter declaration lists using the exact same syntax as [macroref BOOST_LOCAL_FUNCTION].
+For example (see also [@../../test/same_line.cpp =same_line.cpp=]):
+
+[same_line]
+
+As shown by the example above, the [macroref BOOST_LOCAL_FUNCTION_ID] and [macroref BOOST_LOCAL_FUNCTION_ID_TPL] macros are especially useful when it is necessary to invoke them multiple times within a user-defined macro (because the preprocessor expands all nested macros on the same line).
+
+[endsect]
+
+[section Limitations (operators, etc)]
+
+The following table summarizes all C++ function features indicating those features that are not supported by this library for local functions.
+
+[table
+[
+ [ C++ Function Feature ]
+ [ Local Function Support ]
+ [ Comment ]
+]
+[
+ [ `export` ]
+ [ No. ]
+ [ This is not supported because local functions cannot be templates (plus most C++ compilers do not implement `export` at all). ]
+]
+[
+ [ `template<`[^['template-parameter-list]]`>` ]
+ [ No. ]
+ [ This is not supported because local functions are implemented using local classes and __CXX03__ local classes cannot be templates. ]
+]
+[
+ [ `explicit` ]
+ [ No. ]
+ [ This is not supported because local functions are not constructors. ]
+]
+[
+ [ `inline` ]
+ [ Yes. ]
+ [ Local functions can be specified `inline` to improve the chances that __CXX03__ compilers can optimize the local function call run-time (but `inline` local functions cannot be passed as template parameters on __CXX03__ compilers, see the __Advanced_Topics__ section). ]
+]
+[
+ [ `extern` ]
+ [ No. ]
+ [ This is not supported because local functions are always defined locally within the enclosing scope and together with their declarations. ]
+]
+[
+ [ `static` ]
+ [ No. ]
+ [ This is not supported because local functions are not member functions. ]
+]
+[
+ [ `virtual` ]
+ [ No. ]
+ [ This is not supported because local functions are not member functions.
+[footnote
+*Rationale.*
+It would be possible to make a local function class inherit from another local function class.
+However, this "inheritance" feature is not implemented because it seemed of [@http://lists.boost.org/Archives/boost/2010/09/170895.php no use] given that local functions can be bound to one another thus they can simply call each other directly without recurring to dynamic binding or base function calls.
+]
+ ]
+]
+[
+ [ [^/result-type/] ]
+ [ Yes. ]
+ [ This is supported (see the __Tutorial__ section). ]
+]
+[
+ [ [^/function-name/] ]
+ [ Yes. ]
+ [ Local functions are named and they can call themselves recursively but they cannot be operators (see the __Tutorial__ and __Advanced_Topics__ sections). ]
+]
+[
+ [ [^/parameter-list/] ]
+ [ Yes. ]
+ [ This is supported and it also supports the `auto` and `register` storage classifiers, default parameters, and binding of variables in scope (see the __Tutorial__ and __Advanced_Topics__ sections). ]
+]
+[
+ [ Trailing `const` qualifier ]
+ [ No. ]
+ [ This is not supported because local functions are not member functions. ]
+]
+[
+ [ Trailing `volatile` qualifier ]
+ [ No. ]
+ [ This is not supported because local functions are not member functions. ]
+]
+]
+
+[heading Operators]
+
+Local functions cannot be operators.
+Naming a local function `operator...` will generate a compile-time error.
+[footnote
+*Rationale.*
+This is the because a local function name must be a valid local variable name (the local variable used to hold the local functor) and operators cannot be used as local variable names.
+]
+
+For example, the following code does not compile (see also [@../../test/operator_error.cpp =operator_error.cpp=]):
+
+[operator_error]
+
+[heading Goto]
+
+It is possible to jump with a `goto` within the local function body.
+For example, the following compiles (see also [@../../test/goto.cpp =goto.cpp=]):
+
+[goto]
+
+However, it is not possible to jump with a `goto` from within the local function body to to a label defined in the enclosing scope.
+For example, the following does not compile (see also [@../../test/goto_error.cpp =goto_error.cpp=]):
+
+[goto_error]
+
+[endsect]
+
+[endsect]
+
diff --git a/libs/local_function/doc/alternatives.qbk b/libs/local_function/doc/alternatives.qbk
new file mode 100644
index 000000000..bf7f00cdf
--- /dev/null
+++ b/libs/local_function/doc/alternatives.qbk
@@ -0,0 +1,262 @@
+
+[/ Copyright (C) 2009-2012 Lorenzo Caminiti ]
+[/ Distributed under the Boost Software License, Version 1.0 ]
+[/ (see accompanying file LICENSE_1_0.txt or a copy at ]
+[/ http://www.boost.org/LICENSE_1_0.txt) ]
+[/ Home at http://www.boost.org/libs/local_function ]
+
+[section:alternatives Annex: Alternatives]
+
+This section compares the features offered by this library with similar features offered by C++ and by other libraries.
+
+[heading Features]
+
+The following table compares local function features.
+
+[table
+[
+ [ Local Function Feature ]
+ [ Boost.LocalFunction ]
+ [ C++11 Lambda Function (Not C++03) ]
+ [ Local Functor ]
+ [ 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. ]
+]
+[
+ [ ['Can be defined using C++ statement syntax] ]
+ [ Yes.
+Plus eventual compiler errors and debugging retain their usual meaning and format. ]
+ [ Yes.
+Plus eventual compiler errors and debugging retain their usual meaning and format. ]
+ [ Yes.
+Plus eventual compiler errors and debugging retain their usual meaning and format. ]
+ [ Yes.
+Plus eventual compiler errors and debugging retain their usual meaning and format. ]
+ [ 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). ]
+]
+[
+ [ ['Can be passed as template parameter (e.g., to STL algorithms)] ]
+ [ Yes.
+The __CXX03__ 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). ]
+ [ Yes. ]
+ [ No on __CXX03__ compilers (but yes on __CXX11__ compilers and some compilers like MSVC 8.0, see __N2657__). ]
+ [ Yes. ]
+ [ Yes. ]
+]
+[
+ [ ['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 using `this_`). ]
+ [ 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 (see below). ]
+ [ No.
+Programmers must manually program functor data members and explicitly specify their types to access variables in scope. ]
+ [ No.
+Programmers must manually program functor data members and explicitly specify their types to access variables in scope. ]
+ [ 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 function parameter type] ]
+ [ No (local functions cannot be function templates). ]
+ [ No (__CXX11__ lambdas cannot be function templates). ]
+ [ No (local classes cannot have member function templates). ]
+ [ Yes. ]
+ [ Yes. ]
+]
+]
+
+[*C++11 Lambda Function]
+
+__CXX11_lambda_functions__ have most of the features of this library plus some additional feature (see also the example in the __Introduction__ section):
+
+* __CXX11_lambda_functions__ can be defined within expressions while this library local functions can only be defined at declaration scope.
+* __CXX11_lambda_functions__ are only supported by the __CXX11__ standard so they are not supported by all C++ compilers.
+This library local functions can be programmed also on __CXX03__ compilers (and they have performances comparable to __CXX11_lambda_functions__ on __CXX11__ compilers).
+* __CXX11_lambda_functions__ do not allow to bind variables in scope by constant reference.
+Because a variable cannot be bound by constant reference, __CXX11_lambda_functions__ can bind a variable by constant only if the variable is `CopyConstructible` and the binding requires a (potentially expensive) extra copy operation.
+Constant reference binding is instead supported by this library.
+* __CXX11_lambda_functions__ do not allow to bind data members selectively without binding also the object `this` while this library local functions can bind either selected data members or the entire object `this` (using `this_`).
+* __CXX11_lambda_functions__ provide a short-hand syntax to bind all variables in scope at once (`&` or `=`) while this library local function always require to bind variables naming them one-by-one.
+
+For example, for non-copyable objects (see also [@../../example/noncopyable_cxx11_lambda_error.cpp =noncopyable_cxx11_lambda_error.cpp=] and [@../../example/noncopyable_local_function.cpp =noncopyable_local_function.cpp=]):
+
+[table
+ [ [C++11 Lambda Function] [Boost.LocalFunction] ]
+ [ [[noncopyable_cxx11_lambda_error]] [[noncopyable_local_function]] ]
+]
+
+Or, for objects with expensive copy operations (see also [@../../example/expensive_copy_cxx11_lambda.cpp =expensive_copy_cxx11_lambda.cpp=] and [@../../example/expensive_copy_local_function.cpp =expensive_copy_local_function.cpp=]):
+
+[table
+ [ [C++11 Lambda Function] [Boost.LocalFunction] ]
+ [ [[expensive_copy_cxx11_lambda]] [[expensive_copy_local_function]] ]
+]
+
+When constant binding functionality is needed for __CXX11_lambda_functions__, the best alternative might be to bind an extra local variable declared constant and initialized to the original variable (for example, see /constant blocks/ implemented with __CXX11_lambda_functions__ in the __Examples__ section).
+
+[*Local Functor]
+
+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
+ [ [Local Functor] [Boost.LocalFunction] ]
+ [ [[add_local_functor]] [[add]] ]
+]
+
+[*Global Functor]
+
+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=]):
+
+[table
+ [ [Global Functor] [Boost.LocalFunction] ]
+ [ [[add_global_functor]] [[add]] ]
+]
+
+However, note that global functors do not allow to define the function locally so they are not a real alternative implementation of local functions.
+
+[*Boost.Phoenix]
+
+The following example compares local functions with __Boost_Phoenix__ (see also [@../../example/add_phoenix.cpp =add_phoenix.cpp=] and [@../../test/add.cpp =add.cpp=]):
+
+[table
+ [ [Boost.Phoenix] [Boost.LocalFunction] ]
+ [ [[add_phoenix]] [[add]] ]
+]
+
+The comparison in this section does not include the __Boost_Lambda__ library because that library is obsolete and it was replaced by __Boost_Phoenix__.
+The __Boost_Phoenix__ library version 3.0 is used for this comparison.
+
+[heading Performances]
+
+The following tables compare run-times, compile-times, and binary sizes for the different alternatives to local functions presented in this section.
+
+Overall, this library has compile-times and generates binary sizes similar to the ones of the other approaches.
+This library run-times on __CXX03__ 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 __CXX11__ features enabled [^-std=c++0x], see also __N2657__ and __Boost_Config__'s `BOOST_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS`) this library automatically generates optimized code that runs as fast as the fastest of the other approaches (see the "Boost.LocalFunction" approach below).
+When this library local function is specified `inline` (see the "Boost.LocalFunction Inline" approach below and the __Advanced_Topics__ section) its run-times are always comparable to both the "Local Functor" and "Global Functor" approaches.
+However, in these cases the local function cannot be portably passed as template parameter (see __N2657__ and __Boost_Config__'s `BOOST_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS`) so `std::for_each` is replaced by a for-loop (on MSVC the for-loop, and not the local function in fact the same applies to local functors, was measured to have worst performances than using `std::for_each`).
+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 __CXX03__ compliant compilers (e.g., GCC 4.5.3 without [^-std=c++0x]) this library needs to use a function pointer in order to portably 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 (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 __CXX11__ features enabled [^-std=c++0x], see __Boost_Config__'s `BOOST_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS`) 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 __CXX03__ 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 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 compiler from inlining function objects also other approaches like __CXX11_lambda_functions__ and __Boost_Phoenix__ /could/ start to show higher run-times even when optimization is enabled).
+
+The following commands were executed from the library example directory to measure compile-time, binary size, and run-time respectively:
+
+[pre
+> touch <FILE_NAME>.cpp # force recompilation
+> python chrono.py bjam {release|debug} <FILE_NAME> # compile-time
+> size <FILE_NAME> # binary size
+> ./<FILE_NAME> # 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]
+ [Source 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_cxx11_lambda.png]]
+ [__CXX11__ Lambda Function
+[footnote
+Measurements available only for __CXX11__ compilers.
+]
+ ]
+ [[@../../example/profile_cxx11_lambda.cpp =profile_cxx11_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 Lambda Functions and "Local Classes as Template Parameters" ([^bjam cxxflags=-std=c++0x ...])] ]
+ [ [
+ [*Compiled with =bjam release ...= for maximum optimization (=-O3 -finline-functions=)]
+ [$../../example/profile_gcc_cxx11_release.png [width 13in] [height 10in]]
+ ] ]
+ [ [
+ [*Compiled with =bjam debug ...= for no optimization (=-O0 -fno-inline=)]
+ [$../../example/profile_gcc_cxx11_debug.png [width 13in] [height 10in]]
+ ] ]
+]
+
+[table
+ [ [MSVC 8.0 With "Local Classes as Template Parameters" (Without C++11 Lambda Functions)] ]
+ [ [
+ [*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 __CXX03__ Only (Without __CXX11__ Lambda Functions and Without "Local Classes 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]
+
diff --git a/libs/local_function/doc/bibliography.qbk b/libs/local_function/doc/bibliography.qbk
new file mode 100644
index 000000000..1db2d998d
--- /dev/null
+++ b/libs/local_function/doc/bibliography.qbk
@@ -0,0 +1,23 @@
+
+[/ Copyright (C) 2009-2012 Lorenzo Caminiti ]
+[/ Distributed under the Boost Software License, Version 1.0 ]
+[/ (see accompanying file LICENSE_1_0.txt or a copy at ]
+[/ http://www.boost.org/LICENSE_1_0.txt) ]
+[/ Home at http://www.boost.org/libs/local_function ]
+
+[section Bibliography]
+
+This section lists all the bibliographic references cited by this documentation.
+
+__N1613__ Thorsten Ottosen. /Proposal to add Design by Contract to C++./ The C++ Standards Committee, document no. N1613=04-0053, 2004.
+
+__N2511__ Alisdair Meredith. /Named Lambdas and Local Functions./ The C++ Standards Committee, document no. N2511=08-0021, 2008.
+
+__N2529__ Jaakko Jarvi, John Freeman, Lawrence Crowl. /Lambda Expressions and Closures: Wording for Monomorphic Lambdas (Revision 3)./ The C++ Standards Committee, document no. N2529=08-0039, 2008.
+
+__N2550__ Jaakko Jarvi, John Freeman, Lawrence Crowl. /Lambda Expressions and Closures: Wording for Monomorphic Lambdas (Revision 4)./ The C++ Standards Committee, document no. N2550=08-0060, 2008.
+
+__N2657__ John Spicer. /Local and Unamed Types as Template Arguments./ The C++ Standard Committee, document no. N2657=08-0167, 2008.
+
+[endsect]
+
diff --git a/libs/local_function/doc/examples.qbk b/libs/local_function/doc/examples.qbk
new file mode 100644
index 000000000..db33d9313
--- /dev/null
+++ b/libs/local_function/doc/examples.qbk
@@ -0,0 +1,190 @@
+
+[/ Copyright (C) 2009-2012 Lorenzo Caminiti ]
+[/ Distributed under the Boost Software License, Version 1.0 ]
+[/ (see accompanying file LICENSE_1_0.txt or a copy at ]
+[/ http://www.boost.org/LICENSE_1_0.txt) ]
+[/ Home at http://www.boost.org/libs/local_function ]
+
+[section Examples]
+
+This section lists some examples that use this library.
+
+[section GCC Lambdas (without C++11)]
+
+Combing local functions with the non-standard [@http://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html statement expression] extension of the GCC compiler, it is possible to implement lambda functions for GCC compilers even without __CXX11__ support.
+
+[warning
+This code only works on compilers that support GCC statement expression extension or that support __CXX11_lambda_functions__.
+]
+
+For example (see also [@../../example/gcc_lambda.cpp =gcc_lambda.cpp=] and [@../../example/gcc_cxx11_lambda.cpp =gcc_cxx11_lambda.cpp=]):
+
+[table
+ [ [With Local Functions (GCC only)] [C++11 Lambdas] ]
+ [ [[gcc_lambda]] [[gcc_cxx11_lambda]] ]
+]
+
+The GCC lambda function macros are implemented using local functions (see also [@../../example/gcc_lambda.hpp =gcc_lambda.hpp=]):
+
+[gcc_lambda_macro]
+[gcc_lambda_end_macro]
+
+This is possible because GCC statement expressions allow to use declaration statements within expressions and therefore to declare a local function within an expression.
+The macros automatically detect if the compiler supports __CXX11_lambda_functions__ in which case the implementation uses native lambdas instead of local functions in GCC statement expressions.
+However, __CXX11_lambda_functions__ do not support constant binding so it is best to only use `const bind variable` (same as `=variable` for __CXX11_lambda_functions__) and `bind& variable` (same as `&variable` for __CXX11_lambda_functions__') because these have the exact same semantic between the local function and the native lambda implementations.
+Furthermore, local functions allow to bind data members directly while __CXX11_lambda_functions__ require to access data members via binding the object `this`.
+Unfortunately, the short-hand binds `&` and `=` of __CXX11_lambda_functions__ (which automatically bind all variables in scope either by reference or value) are not supported by these GCC lambda function macros because they are not supported by local functions.
+Finally, the result type `return `[^['result-type]] is optional and it is assumed `void` when it is not specified (same as with __CXX11_lambda_functions__).
+
+[endsect]
+
+[section Constant Blocks]
+
+It is possible to use local functions to check assertions between variables that are made constant within the asserted expressions.
+This is advantageous because assertions are not supposed to change the state of the program and ideally the compiler will not compile assertions that modify variables.
+
+For example, consider the following assertion where by mistake we programmed `operator=` instead of `operator==`:
+
+ int x = 1, y = 2;
+ assert(x = y); // Mistakenly `=` instead of `==`.
+
+Ideally this code will not compile instead this example not only compiles but the assertion even passes the run-time check and no error is generated at all.
+The __N1613__ paper introduces the concept of a /const-block/ which could be used to wrap the assertion above and catch the programming error at compile-time.
+Similarly, the following code will generate a compile-time error when `operator=` is mistakenly used instead of `operator==` because both `x` and `y` are made constants (using local functions) within the block of code performing the assertion (see also [@../../example/const_block_error.cpp =const_block_error.cpp=]):
+
+[table
+ [ [With Local Functions] [N1613 Const-Blocks] ]
+ [ [[const_block]] [``
+ int x = 1, y = 2;
+ const { // Constant block.
+ assert(x = y); // Compiler error.
+ }
+ ``] ]
+]
+
+The constant block macros are implemented using local functions (see also [@../../example/const_block.hpp =const_block.hpp=]):
+
+[const_block_macro]
+[const_block_end_macro]
+
+The constant block macros are implemented using a local function which binds by constant reference `const bind&` all the specified variables (so the variables are constant within the code block but they do not need to be `CopyConstructible` and no extra copy is performed).
+The local function executes the `assert` instruction in its body and it is called immediately after it is defined.
+More in general, constant blocks can be used to evaluate any instruction (not just assertions) within a block were all specified variables are constant.
+
+Unfortunately, constant blocks cannot be implemented with __CXX11_lambda_functions__ because these do not support constant binding.
+Variables bound by value using __CXX11_lambda_functions__ (`variable`, `=variable`, and `=`) are constant but they are required to be `CopyConstructible` and they introduce potentially expensive copy operations.
+[footnote
+Ideally, __CXX11_lambda_functions__ would allow to bind variables also using `const& variable` (constant reference) and `const&` (all variables by constant reference).
+]
+Of course it is always possible to introduce extra constant variables and bind these variables to the __CXX11_lambda_functions__ but the constant block code will then have to manage the declaration and initialization of these extra variables plus it will have to use the extra variable names instead of the original variable names:
+
+[const_block_cxx11_lambda]
+
+In many cases the use of an extra constant variable `const_x` can be acceptable but in other cases it might be preferable to maintain the same variable name `x` within the function body.
+
+[endsect]
+
+[section Scope Exits]
+
+Scope exits allow to execute arbitrary code at the exit of the enclosing scope and they are provided by the __Boost_ScopeExit__ library.
+
+For curiosity, here we show how to re-implement scope exits using local functions.
+One small advantage of scope exits that use local functions is that they support constant binding.
+__Boost_ScopeExit__ does not directly support constant binding (however, it is always possible to introduce an extra `const` local variable, assign it to the value to bind, and then bind the `const` variable so to effectively have constant binding with __Boost_ScopeExit__ as well).
+
+[note
+In general, the authors recommend to use __Boost_ScopeExit__ instead of the code listed by this example whenever possible (because __Boost_ScopeExit__ is a library deliberately designed to support the scope exit construct).
+]
+
+The following example binds `p` by constant reference so this variable cannot be modified within the scope exit body but it is not copied and it will present the value it has at the exit of the enclosing scope and not at the scope exit declaration (see also [@../../example/scope_exit.cpp =scope_exit.cpp=]):
+
+[table
+ [ [With Local Functions] [Boost.ScopeExit] ]
+ [ [[scope_exit]] [``
+ person& p = persons_.back();
+ person::evolution_t checkpoint = p.evolution_;
+
+ BOOST_SCOPE_EXIT(checkpoint, &p, this_) { // Or extra variable `const_p`.
+ if (checkpoint == p.evolution_) this_->persons_.pop_back();
+ } BOOST_SCOPE_EXIT_END
+ ``] ]
+]
+
+The scope exit macros are implemented by passing a local function when constructing an object of the following class (see also [@../../example/scope_exit.hpp =scope_exit.hpp=]):
+
+[scope_exit_class]
+[scope_exit_macro]
+[scope_exit_end_macro]
+
+A local variable within the enclosing scope is used to hold the object so the destructor will be invoked at the exit of the enclosing scope and it will in turn call the local function executing the scope exit instructions.
+The scope exit local function has no parameter and `void` result type but it supports binding and constant binding.
+
+[endsect]
+
+[section Boost.Phoenix Functions]
+
+Local functions can be used to create __Boost_Phoenix__ functions.
+For example (see also [@../../example/phoenix_factorial_local.cpp =phoenix_factorial_local.cpp=] and [@../../example/phoenix_factorial.cpp =phoenix_factorial.cpp=]):
+
+[table
+ [ [Local Functions] [Global Functor] ]
+ [ [[phoenix_factorial_local]] [[phoenix_factorial]] ]
+]
+
+This is presented here mainly as a curiosity because __Boost_Phoenix__ functions created from local functions have the important limitation that they cannot be polymorphic.
+[footnote
+*Rationale.*
+Local functions can only be monomorphic because they are implemented using local classes and local classes cannot be templates in C++ (not even in __CXX11__).
+]
+Therefore, in many cases creating the __Boost_Phoenix__ function from global functors (possibly with the help of __Boost_Phoenix__ adaptor macros) might be a more useful.
+
+[endsect]
+
+[section Closures]
+
+The following are examples of [@http://en.wikipedia.org/wiki/Closure_(computer_science) closures] that illustrate how to return local functions to the calling scope (note how extra care is taken in order to ensure that all bound variables remain valid at the calling scope):
+
+[table
+ [ [Files] ]
+ [ [[@../../test/return_inc.cpp =return_inc.cpp=]] ]
+ [ [[@../../test/return_this.cpp =return_this.cpp=]] ]
+ [ [[@../../test/return_setget.cpp =return_setget.cpp=]] ]
+ [ [[@../../test/return_derivative.cpp =return_derivative.cpp=]] ]
+]
+
+[endsect]
+
+[section GCC Nested Functions]
+
+The GCC C compiler supports local functions as a non-standard extension under the name of [@http://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html nested functions].
+Note that nested functions are exclusively a C extension of the GCC compiler (they are not supported for C++ not even by the GCC compiler, and they are not part of any C or C++ standard, nor they are supported by other compilers like MSVC).
+
+The following examples are taken form the GCC nested function documentation and programmed using local functions:
+
+[table
+ [ [Files] ]
+ [ [[@../../example/gcc_square.cpp =gcc_square.cpp=]] ]
+ [ [[@../../example/gcc_access.cpp =gcc_access.cpp=]] ]
+ [ [[@../../example/gcc_store.cpp =gcc_store.cpp=]] ]
+]
+
+[endsect]
+
+[section N-Papers]
+
+The following examples are taken from different C++ "N-papers" and programmed using local functions:
+
+[table
+ [ [Files] [Notes] ]
+ [ [[@../../example/n2550_find_if.cpp =n2550_find_if.cpp=]] [
+This example is adapted from __N2550__ (__CXX11_lambda_functions__): It passes a local function to the STL algorithm `std::find_if`.
+ ] ]
+ [ [[@../../example/n2529_this.cpp =n2529_this.cpp=]] [
+This example is adapted from __N2529__ (__CXX11_lambda_functions__): It binds the object in scope `this` to a local function.
+ ] ]
+]
+
+[endsect]
+
+[endsect]
+
diff --git a/libs/local_function/doc/getting_started.qbk b/libs/local_function/doc/getting_started.qbk
new file mode 100644
index 000000000..cdc1628fd
--- /dev/null
+++ b/libs/local_function/doc/getting_started.qbk
@@ -0,0 +1,73 @@
+
+[/ Copyright (C) 2009-2012 Lorenzo Caminiti ]
+[/ Distributed under the Boost Software License, Version 1.0 ]
+[/ (see accompanying file LICENSE_1_0.txt or a copy at ]
+[/ http://www.boost.org/LICENSE_1_0.txt) ]
+[/ Home at http://www.boost.org/libs/local_function ]
+
+[section Getting Started]
+
+This section explains how to setup a system to use this library.
+
+[section This Documentation]
+
+Programmers should have enough knowledge to use this library after reading the __Introduction__, __Getting_Started__, and __Tutorial__ sections.
+The __Advanced_Topics__ and __Reference__ sections can be consulted at a later point to gain a more advanced knowledge of the library.
+All the other sections of this documentation can be considered optional.
+
+Some footnotes are marked by the word "*Rationale*".
+They explain reasons behind decisions made during the design and implementation of this library.
+
+In most of the examples presented in this documentation, the Boost.Detail/LightweightTest (=boost/detail/lightweight_test.hpp=) macro `BOOST_TEST` is used to check correctness conditions.
+The `BOOST_TEST` macro is conceptually similar to `assert` but a failure of the checked condition does not abort the program, instead it makes `boost::report_errors` return a non-zero program exit code.
+[footnote
+*Rationale.*
+Using Boost.Detail/LightweightTest allows to add the examples to the library regression tests so to make sure that they always compile and run correctly.
+]
+
+[endsect]
+
+[section Compilers and Platforms]
+
+The implementation of this library uses preprocessor and template meta-programming (as supported by __Boost_Preprocessor__ and __Boost_MPL__), templates with partial specializations and function pointers (similarly to __Boost_Function__), and automatic type deduction (as supported by __Boost_Typeof__).
+The authors originally developed and tested the library on:
+
+# GNU Compiler Collection (GCC) C++ 4.5.1 on Ubuntu Linux 10.
+# GCC 4.3.4 and 4.5.3 (with and without __CXX11__ features enabled `-std=c++0x`) on Cygwin.
+# Miscrosoft Visual C++ (MSVC) 8.0 on Windows XP and Windows 7.
+
+See the library [@http://www.boost.org/development/tests/release/developer/local_function.html regressions test results] for detailed information on supported compilers and platforms.
+
+[endsect]
+
+[section Installation]
+
+This library is composed of header files only.
+Therefore there is no pre-compiled object file which needs to be installed or linked.
+Programmers can simply instruct the C++ compiler where to find the library header files (`-I` option for GCC, `/I` option for MSVC, etc) and they can start compiling code using this library.
+
+The library implementation uses __Boost_Typeof__ to automatically deduce the types of bound variables (see the __Tutorial__ section).
+In order to compile code in type-of emulation mode, all types should be properly registered using `BOOST_TYPEOF_REGISTER_TYPE` and `BOOST_TYPEOF_REGISTER_TEMPLATE`, or appropriate __Boost_Typeof__ headers should be included (see the source code of most examples presented in this documentation).
+
+The followings are part of the library private API, they are not documented, and they should not be directly used by programmers:
+[footnote
+*Rationale.*
+This library concatenates symbols specified by the programmers (e.g., the local function name) with other symbols (e.g., special prefixes or file line numbers) to make internal symbols with unique names to avoid name clashes.
+These symbols are separated by the letter "`X`" when they are concatenated so they read more easily during debugging (the underscore character "`_`" could not be used instead of the letter "`X`" because if the original symbols already contained a leading or trailing underscore, the concatenation could result in a symbol with double underscores "`__`" which is reserved by the C++ standard).
+The "aux" symbols are private to this library while the "detail" symbols may be used within Boost by other libraries but they are still not part of this library public API.
+]
+
+* Any symbol defined by files within the =boost/local_function/aux_/= or =boost/local_function/detail/= directory (these header files should not be directly included by programmers).
+* Any symbol within the `boost::local_function::aux` or `boost::local_function::detail` namespace.
+* Any symbol prefixed by `boost_local_function_aux_...` or `boost_local_function_detail_...` (regardless of its namespace).
+* Any symbol prefixed by `BOOST_LOCAL_FUNCTION_AUX_...` or `BOOST_LOCAL_FUNCTION_DETAIL_...` (regardless of its namespace).
+
+Some of the library behaviour can be changed at compile-time by defining special /configuration macros/.
+If a configuration macro is left undefined, the library will use an appropriate default value for it.
+All configuration macros are defined in the header file [headerref boost/local_function/config.hpp].
+It is strongly recommended not to change the library configuration macro definitions unless strictly necessary.
+
+[endsect]
+
+[endsect]
+
diff --git a/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION.html b/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION.html
new file mode 100644
index 000000000..d8708061b
--- /dev/null
+++ b/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION.html
@@ -0,0 +1,103 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Macro BOOST_LOCAL_FUNCTION</title>
+<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="up" href="reference.html#header.boost.local_function_hpp" title="Header &lt;boost/local_function.hpp&gt;">
+<link rel="prev" href="reference.html" title="Reference">
+<link rel="next" href="BOOST_LOCAL_FUNCTION_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_TPL">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
+<td align="center"><a href="../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="reference.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_TPL.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="refentry">
+<a name="BOOST_LOCAL_FUNCTION"></a><div class="titlepage"></div>
+<div class="refnamediv">
+<h2><span class="refentrytitle">Macro BOOST_LOCAL_FUNCTION</span></h2>
+<p>BOOST_LOCAL_FUNCTION &#8212; This macro is used to start a local function declaration. </p>
+</div>
+<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
+<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="reference.html#header.boost.local_function_hpp" title="Header &lt;boost/local_function.hpp&gt;">boost/local_function.hpp</a>&gt;
+
+</span>BOOST_LOCAL_FUNCTION(declarations)</pre></div>
+<div class="refsect1">
+<a name="id880748"></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>
+ <span class="identifier">result_type</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="identifier">declarations</span><span class="special">)</span> <span class="special">{</span>
+ <span class="special">...</span> <span class="comment">// Body code.</span>
+ <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">qualified_name</span><span class="special">)</span>
+ <span class="special">...</span>
+<span class="special">}</span>
+</pre>
+<p>As usual, exceptions specifications can be optionally programmed just after the macro and before the body code block <code class="computeroutput">{ ... }</code> (but the exception specifications will only apply to the body code and not to the library code automatically generated by the macro expansion, see the <a class="link" href="boost_localfunction/advanced_topics.html" title="Advanced Topics"> Advanced Topics</a> section).</p>
+<p>Within templates, the special macros <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_TPL">BOOST_LOCAL_FUNCTION_TPL</a></code> and <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_NAME_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_NAME_TPL">BOOST_LOCAL_FUNCTION_NAME_TPL</a></code> must be used.</p>
+<p><span class="bold"><strong>Parameters:</strong></span> </p>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<tbody><tr>
+<td><span class="bold"><strong><code class="computeroutput">declarations</code></strong></span></td>
+<td>On compilers that support variadic macros, the parameter declarations are defined by the following grammar: <pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"> <span class="identifier">declarations</span><span class="special">:</span>
+ <span class="keyword">void</span> <span class="special">|</span> <span class="identifier">declaration_tuple</span> <span class="special">|</span> <span class="identifier">declaration_sequence</span>
+ <span class="identifier">declaration_tuple</span><span class="special">:</span>
+ <span class="identifier">declaration</span><span class="special">,</span> <span class="identifier">declaration</span><span class="special">,</span> <span class="special">...</span>
+ <span class="identifier">declaration_sequence</span><span class="special">:</span>
+ <span class="special">(</span><span class="identifier">declaration</span><span class="special">)</span> <span class="special">(</span><span class="identifier">declaration</span><span class="special">)</span> <span class="special">...</span>
+ <span class="identifier">declaration</span><span class="special">:</span>
+ <span class="identifier">bound_variable</span> <span class="special">|</span> <span class="identifier">parameter</span> <span class="special">|</span> <span class="identifier">default_value</span> <span class="special">|</span> <span class="identifier">result_type</span>
+ <span class="identifier">bound_variable</span><span class="special">:</span>
+ <span class="special">[</span><span class="keyword">const</span><span class="special">]</span> <span class="identifier">bind</span> <span class="special">[</span><span class="special">(</span><span class="identifier">variable_type</span><span class="special">)</span><span class="special">]</span> <span class="special">[</span><span class="special">&amp;</span><span class="special">]</span> <span class="identifier">variable_name</span>
+ <span class="identifier">parameter</span><span class="special">:</span>
+ <span class="special">[</span><span class="keyword">auto</span> <span class="special">|</span> <span class="keyword">register</span><span class="special">]</span> <span class="identifier">parameter_type</span> <span class="identifier">parameter_name</span>
+ <span class="identifier">default_value</span><span class="special">:</span>
+ <span class="keyword">default</span> <span class="identifier">parameter_default_value</span>
+ <span class="identifier">result_type</span><span class="special">:</span>
+ <span class="keyword">return</span> <span class="identifier">function_result_type</span>
+</pre> On compilers that do not support variadic macros, <code class="computeroutput">declaration_tuple</code> cannot be used: <pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"> <span class="identifier">declarations</span><span class="special">:</span>
+ <span class="keyword">void</span> <span class="special">|</span> <span class="identifier">declaration_sequence</span>
+</pre>(Lexical conventions: <code class="computeroutput">token1 | token2</code> means either <code class="computeroutput">token1</code> or <code class="computeroutput">token2</code>; <code class="computeroutput">[token]</code> means either <code class="computeroutput">token</code> or nothing; <code class="computeroutput">{expression}</code> means the token resulting from the expression.) </td>
+</tr></tbody>
+</table></div>
+<p>
+</p>
+<p>Note that on compilers that support variadic macros, commas can be used to separate the declarations resembling more closely the usual C++ function declaration syntax (this is the preferred syntax). However, for portability, on all C++ compilers (with and without variadic macros) the same library macros also accept parameter declarations specified as a Boost.Preprocessor sequence separated by round parenthesis <code class="computeroutput">()</code>.</p>
+<p>When binding the object <code class="computeroutput">this</code>, the special symbol <code class="computeroutput">this_</code> needs to be used instead of <code class="computeroutput">this</code> as the name of the variable to bind and also within the local function body to access the object. (Mistakenly using <code class="computeroutput">this</code> instead of <code class="computeroutput">this_</code> might not always result in a compiler error and will in general result in undefined behaviour.)</p>
+<p>The result type must either be specified just before the macro or within the macro declarations prefixed by <code class="computeroutput">return</code> (but not in both places).</p>
+<p>Within the local function body it possible to access the result type using <code class="computeroutput">result_type</code>, the type of the first parameter using <code class="computeroutput">arg1_type</code>, the type of the second parameter using <code class="computeroutput">arg2_type</code>, etc. The bound variable types can be accessed using <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_TYPEOF.html" title="Macro BOOST_LOCAL_FUNCTION_TYPEOF">BOOST_LOCAL_FUNCTION_TYPEOF</a></code>.</p>
+<p>This macro cannot be portably expanded multiple times on the same line. In these cases, use the <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_ID.html" title="Macro BOOST_LOCAL_FUNCTION_ID">BOOST_LOCAL_FUNCTION_ID</a></code> macro instead.</p>
+<p>The maximum number of local function parameters (excluding bound variables) is specified by the configuration macro <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>. The maximum number of bound variables is specified by the configuration macro <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>. The configuration macro <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS">BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS</a></code> can be used to force optimizations that reduce the local function call run-time overhead.</p>
+<p><span class="bold"><strong>Note:</strong></span> Local functions are functors so they can be assigned to other functors like <code class="computeroutput">boost::function</code> (see Boost.Function).</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/advanced_topics.html" title="Advanced Topics"> Advanced Topics</a> section, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code>, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_TPL">BOOST_LOCAL_FUNCTION_TPL</a></code>, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_NAME_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_NAME_TPL">BOOST_LOCAL_FUNCTION_NAME_TPL</a></code>, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_TYPEOF.html" title="Macro BOOST_LOCAL_FUNCTION_TYPEOF">BOOST_LOCAL_FUNCTION_TYPEOF</a></code>, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_ID.html" title="Macro BOOST_LOCAL_FUNCTION_ID">BOOST_LOCAL_FUNCTION_ID</a></code>, <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>, <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>, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS">BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS</a></code>. </p>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2009-2012 Lorenzo
+ Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="reference.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_TPL.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html b/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html
new file mode 100644
index 000000000..ed87ec72f
--- /dev/null
+++ b/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html
@@ -0,0 +1,56 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Macro BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX</title>
+<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="up" href="reference.html#header.boost.local_function.config_hpp" title="Header &lt;boost/local_function/config.hpp&gt;">
+<link rel="prev" href="BOOST_LOCAL_FUNCTION_TYPEOF.html" title="Macro BOOST_LOCAL_FUNCTION_TYPEOF">
+<link rel="next" href="BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
+<td align="center"><a href="../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_TYPEOF.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function.config_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="refentry">
+<a name="BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX"></a><div class="titlepage"></div>
+<div class="refnamediv">
+<h2><span class="refentrytitle">Macro BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX</span></h2>
+<p>BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX &#8212; Maximum number of parameters supported by local functions. </p>
+</div>
+<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
+<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="reference.html#header.boost.local_function.config_hpp" title="Header &lt;boost/local_function/config.hpp&gt;">boost/local_function/config.hpp</a>&gt;
+
+</span>BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX</pre></div>
+<div class="refsect1">
+<a name="id883507"></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>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2009-2012 Lorenzo
+ Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_TYPEOF.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function.config_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html b/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html
new file mode 100644
index 000000000..8b8d268ae
--- /dev/null
+++ b/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html
@@ -0,0 +1,56 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Macro BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX</title>
+<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="up" href="reference.html#header.boost.local_function.config_hpp" title="Header &lt;boost/local_function/config.hpp&gt;">
+<link rel="prev" href="BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX">
+<link rel="next" href="BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
+<td align="center"><a href="../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function.config_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="refentry">
+<a name="BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX"></a><div class="titlepage"></div>
+<div class="refnamediv">
+<h2><span class="refentrytitle">Macro BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX</span></h2>
+<p>BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX &#8212; Maximum number of bound variables supported by local functions. </p>
+</div>
+<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
+<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="reference.html#header.boost.local_function.config_hpp" title="Header &lt;boost/local_function/config.hpp&gt;">boost/local_function/config.hpp</a>&gt;
+
+</span>BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX</pre></div>
+<div class="refsect1">
+<a name="id883581"></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>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2009-2012 Lorenzo
+ Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function.config_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html b/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html
new file mode 100644
index 000000000..510b5c0de
--- /dev/null
+++ b/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html
@@ -0,0 +1,66 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Macro BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS</title>
+<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="up" href="reference.html#header.boost.local_function.config_hpp" title="Header &lt;boost/local_function/config.hpp&gt;">
+<link rel="prev" href="BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX">
+<link rel="next" href="boost_localfunction/release_notes.html" title="Release Notes">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
+<td align="center"><a href="../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function.config_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost_localfunction/release_notes.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="refentry">
+<a name="BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS"></a><div class="titlepage"></div>
+<div class="refnamediv">
+<h2><span class="refentrytitle">Macro BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS</span></h2>
+<p>BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS &#8212; Specify when local functions can be passed as template parameters without introducing any run-time overhead. </p>
+</div>
+<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
+<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="reference.html#header.boost.local_function.config_hpp" title="Header &lt;boost/local_function/config.hpp&gt;">boost/local_function/config.hpp</a>&gt;
+
+</span>BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS</pre></div>
+<div class="refsect1">
+<a name="id883656"></a><h2>Description</h2>
+<p>If this macro is defined to <code class="computeroutput">1</code>, this library will assume that the compiler allows to pass local classes as template parameters: </p>
+<pre class="programlisting"> <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">void</span> <span class="identifier">f</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span><span class="special">}</span>
+
+ <span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">struct</span> <span class="identifier">local_class</span> <span class="special">{</span><span class="special">}</span><span class="special">;</span>
+ <span class="identifier">f</span><span class="special">&lt;</span><span class="identifier">local_class</span><span class="special">&gt;</span><span class="special">(</span><span class="special">)</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> This is the case for C++11 compilers and some C++03 compilers (e.g., MSVC), but it is not the case in general for most C++03 compilers (including GCC). This will allow the library to pass local functions as template parameters without introducing any run-time overhead (specifically without preventing the compiler from optimizing local function calls by inlining their assembly code).</p>
+<p>If this macro is defined to <code class="computeroutput">0</code> instead, this library will introduce a run-time overhead associated to resolving a function pointer call in order to still allow to pass the local functions as template parameters.</p>
+<p>It is recommended to leave this macro undefined. In this case, the library will automatically define this macro to <code class="computeroutput">0</code> if the Boost.Config macro <code class="computeroutput">BOOST_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS</code> is defined for the specific compiler, and to <code class="computeroutput">1</code> otherwise.</p>
+<p><span class="bold"><strong>See:</strong></span> <a class="link" href="boost_localfunction/getting_started.html" title="Getting Started"> Getting Started</a> section, <a class="link" href="boost_localfunction/advanced_topics.html" title="Advanced Topics"> Advanced Topics</a> section, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code>. </p>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2009-2012 Lorenzo
+ Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function.config_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost_localfunction/release_notes.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_ID.html b/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_ID.html
new file mode 100644
index 000000000..4f449a3a6
--- /dev/null
+++ b/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_ID.html
@@ -0,0 +1,77 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Macro BOOST_LOCAL_FUNCTION_ID</title>
+<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="up" href="reference.html#header.boost.local_function_hpp" title="Header &lt;boost/local_function.hpp&gt;">
+<link rel="prev" href="BOOST_LOCAL_FUNCTION_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_TPL">
+<link rel="next" href="BOOST_LOCAL_FUNCTION_ID_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_ID_TPL">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
+<td align="center"><a href="../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_TPL.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_ID_TPL.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="refentry">
+<a name="BOOST_LOCAL_FUNCTION_ID"></a><div class="titlepage"></div>
+<div class="refnamediv">
+<h2><span class="refentrytitle">Macro BOOST_LOCAL_FUNCTION_ID</span></h2>
+<p>BOOST_LOCAL_FUNCTION_ID &#8212; This macro allows to declare multiple local functions on the same line. </p>
+</div>
+<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
+<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="reference.html#header.boost.local_function_hpp" title="Header &lt;boost/local_function.hpp&gt;">boost/local_function.hpp</a>&gt;
+
+</span>BOOST_LOCAL_FUNCTION_ID(id, declarations)</pre></div>
+<div class="refsect1">
+<a name="id881677"></a><h2>Description</h2>
+<p>This macro is equivalent to <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code> but it can be expanded multiple times on the same line if different identifiers <code class="computeroutput">id</code> are provided for each expansion (see the <a class="link" href="boost_localfunction/advanced_topics.html" title="Advanced Topics"> Advanced Topics</a> section).</p>
+<p><span class="bold"><strong>Parameters:</strong></span> </p>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<tbody>
+<tr>
+<td><span class="bold"><strong><code class="computeroutput">id</code></strong></span></td>
+<td>A unique identifier token which can be concatenated by the preprocessor (<code class="computeroutput">__LINE__</code>, <code class="computeroutput">local_function_number_1_on_line_123</code>, etc). </td>
+</tr>
+<tr>
+<td><span class="bold"><strong><code class="computeroutput">declarations</code></strong></span></td>
+<td>Same as the <code class="computeroutput">declarations</code> parameter of the <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code> macro. </td>
+</tr>
+</tbody>
+</table></div>
+<p>
+</p>
+<p>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 should be used to end each one of the multiple local function declarations as usual (and it will specify a unique name for each local function).</p>
+<p>Within templates, the special macros <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_ID_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_ID_TPL">BOOST_LOCAL_FUNCTION_ID_TPL</a></code> must be used.</p>
+<p><span class="bold"><strong>Note:</strong></span> This macro can be useful when the local function macros are expanded within user-defined macros (because macros all expand on the same line). On some compilers (e.g., MSVC which supports the non-standard <code class="computeroutput">__COUNTER__</code> macro) it might not be necessary to use this macro but the use of this macro when expanding multiple local function macros on the same line is always necessary to ensure portability (this is because this library can only portably use <code class="computeroutput">__LINE__</code> to internally generate unique identifiers).</p>
+<p><span class="bold"><strong>See:</strong></span> <a class="link" href="boost_localfunction/advanced_topics.html" title="Advanced Topics"> Advanced Topics</a> section, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code>, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code>, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_ID_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_ID_TPL">BOOST_LOCAL_FUNCTION_ID_TPL</a></code>. </p>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2009-2012 Lorenzo
+ Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_TPL.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_ID_TPL.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_ID_TPL.html b/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_ID_TPL.html
new file mode 100644
index 000000000..a68e7e67d
--- /dev/null
+++ b/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_ID_TPL.html
@@ -0,0 +1,77 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Macro BOOST_LOCAL_FUNCTION_ID_TPL</title>
+<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="up" href="reference.html#header.boost.local_function_hpp" title="Header &lt;boost/local_function.hpp&gt;">
+<link rel="prev" href="BOOST_LOCAL_FUNCTION_ID.html" title="Macro BOOST_LOCAL_FUNCTION_ID">
+<link rel="next" href="BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
+<td align="center"><a href="../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_ID.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_NAME.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="refentry">
+<a name="BOOST_LOCAL_FUNCTION_ID_TPL"></a><div class="titlepage"></div>
+<div class="refnamediv">
+<h2><span class="refentrytitle">Macro BOOST_LOCAL_FUNCTION_ID_TPL</span></h2>
+<p>BOOST_LOCAL_FUNCTION_ID_TPL &#8212; This macro allows to declare multiple local functions on the same line within templates. </p>
+</div>
+<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
+<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="reference.html#header.boost.local_function_hpp" title="Header &lt;boost/local_function.hpp&gt;">boost/local_function.hpp</a>&gt;
+
+</span>BOOST_LOCAL_FUNCTION_ID_TPL(id, declarations)</pre></div>
+<div class="refsect1">
+<a name="id881854"></a><h2>Description</h2>
+<p>This macro must be used instead of <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_TPL">BOOST_LOCAL_FUNCTION_TPL</a></code> when declaring multiple local functions on the same line 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_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_TPL">BOOST_LOCAL_FUNCTION_TPL</a></code> (see <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_TPL">BOOST_LOCAL_FUNCTION_TPL</a></code> for more information).</p>
+<p><span class="bold"><strong>Parameters:</strong></span> </p>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<tbody>
+<tr>
+<td><span class="bold"><strong><code class="computeroutput">id</code></strong></span></td>
+<td>A unique identifier token which can be concatenated by the preprocessor (<code class="computeroutput">__LINE__</code>, <code class="computeroutput">local_function_number_1_on_line_123</code>, etc). </td>
+</tr>
+<tr>
+<td><span class="bold"><strong><code class="computeroutput">declarations</code></strong></span></td>
+<td>Same as the <code class="computeroutput">declarations</code> parameter of the <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_TPL">BOOST_LOCAL_FUNCTION_TPL</a></code> macro. </td>
+</tr>
+</tbody>
+</table></div>
+<p>
+</p>
+<p>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 should be used to end each one of the multiple local function declarations as usual (and it will specify a unique name for each local function).</p>
+<p>Outside template, the macro <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_ID.html" title="Macro BOOST_LOCAL_FUNCTION_ID">BOOST_LOCAL_FUNCTION_ID</a></code> should be used to declare multiple local functions on the same line.</p>
+<p><span class="bold"><strong>Note:</strong></span> This macro can be useful when the local function macros are expanded within user-defined macros (because macros all expand on the same line). On some compilers (e.g., MSVC which supports the non-standard <code class="computeroutput">__COUNTER__</code> macro) it might not be necessary to use this macro but the use of this macro when expanding multiple local function macros on the same line is always necessary to ensure portability (this is because this library can only portably use <code class="computeroutput">__LINE__</code> to internally generate unique identifiers).</p>
+<p><span class="bold"><strong>See:</strong></span> <a class="link" href="boost_localfunction/advanced_topics.html" title="Advanced Topics"> Advanced Topics</a> section, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_TPL">BOOST_LOCAL_FUNCTION_TPL</a></code>, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code>, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_ID.html" title="Macro BOOST_LOCAL_FUNCTION_ID">BOOST_LOCAL_FUNCTION_ID</a></code>. </p>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2009-2012 Lorenzo
+ Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_ID.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_NAME.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_NAME.html b/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_NAME.html
new file mode 100644
index 000000000..532a50c37
--- /dev/null
+++ b/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_NAME.html
@@ -0,0 +1,90 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Macro BOOST_LOCAL_FUNCTION_NAME</title>
+<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="up" href="reference.html#header.boost.local_function_hpp" title="Header &lt;boost/local_function.hpp&gt;">
+<link rel="prev" href="BOOST_LOCAL_FUNCTION_ID_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_ID_TPL">
+<link rel="next" href="BOOST_LOCAL_FUNCTION_NAME_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_NAME_TPL">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
+<td align="center"><a href="../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_ID_TPL.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_NAME_TPL.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="refentry">
+<a name="BOOST_LOCAL_FUNCTION_NAME"></a><div class="titlepage"></div>
+<div class="refnamediv">
+<h2><span class="refentrytitle">Macro BOOST_LOCAL_FUNCTION_NAME</span></h2>
+<p>BOOST_LOCAL_FUNCTION_NAME &#8212; This macro is used to end a local function declaration specifying its name. </p>
+</div>
+<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
+<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="reference.html#header.boost.local_function_hpp" title="Header &lt;boost/local_function.hpp&gt;">boost/local_function.hpp</a>&gt;
+
+</span>BOOST_LOCAL_FUNCTION_NAME(qualified_name)</pre></div>
+<div class="refsect1">
+<a name="id882675"></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>
+ <span class="identifier">result_type</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="identifier">declarations</span><span class="special">)</span> <span class="special">{</span>
+ <span class="special">...</span> <span class="comment">// Body code.</span>
+ <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">qualified_name</span><span class="special">)</span>
+ <span class="special">...</span>
+<span class="special">}</span>
+</pre>
+<p>Within templates, the special macros <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_TPL">BOOST_LOCAL_FUNCTION_TPL</a></code> and <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_NAME_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_NAME_TPL">BOOST_LOCAL_FUNCTION_NAME_TPL</a></code> must be used.</p>
+<p><span class="bold"><strong>Parameters:</strong></span> </p>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<tbody><tr>
+<td><span class="bold"><strong><code class="computeroutput">qualified_name</code></strong></span></td>
+<td>The name of the local function optionally qualified as follow: <pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"> <span class="identifier">name</span><span class="special">:</span>
+ <span class="special">[</span><span class="keyword">inline</span><span class="special">]</span> <span class="special">[</span><span class="identifier">recursive</span><span class="special">]</span> <span class="identifier">local_function_name</span>
+</pre> (Lexical conventions: <code class="computeroutput">token1 | token2</code> means either <code class="computeroutput">token1</code> or <code class="computeroutput">token2</code>; <code class="computeroutput">[token]</code> means either <code class="computeroutput">token</code> or nothing; <code class="computeroutput">{expression}</code> means the token resulting from the expression.) </td>
+</tr></tbody>
+</table></div>
+<p>
+</p>
+<p>The local function name can be qualified by prefixing it with the keyword <code class="computeroutput">inline</code> (see the <a class="link" href="boost_localfunction/advanced_topics.html" title="Advanced Topics"> Advanced Topics</a> section): </p>
+<pre class="programlisting"> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="keyword">inline</span> <span class="identifier">local_function_name</span><span class="special">)</span>
+</pre>
+<p> This increases the chances that the compiler will be able to inline the local function calls (thus reducing run-time). However, inline local functions cannot be passed as template parameters (e.g., to <code class="computeroutput">std::for_each</code>) or assigned to other functors (e.g., to <code class="computeroutput">boost::function</code>). That is true on C++03 compilers but inline local functions can instead be passed as template parameters on C++11 compilers. On C++11 compilers, there is no need to declare a local function lined because this library will automatically use C++11 specific features to inline the local function while always allowing to pass it as a template parameter. This optimization is automatically enabled when the Boost.Config macro <code class="computeroutput">BOOST_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS</code> is not defined but it also be forced using <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS">BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS</a></code>.</p>
+<p>The local function name can also be qualified by prefixing it with the "keyword" <code class="computeroutput">recursive</code> (see the <a class="link" href="boost_localfunction/advanced_topics.html" title="Advanced Topics"> Advanced Topics</a> section): </p>
+<pre class="programlisting"> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">recursive</span> <span class="identifier">local_function_name</span><span class="special">)</span>
+</pre>
+<p> This allows the local function to recursively call itself from its body (as usual in C++). However, recursive local functions should only be called within their declaration scope (otherwise the result is undefined behaviour). Finally, compilers have not been observed to be able to inline recursive local function calls, not even when the recursive local function is also declared inline: </p>
+<pre class="programlisting"> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">inline</span> <span class="identifier">recursive</span> <span class="identifier">local_function_name</span><span class="special">)</span>
+</pre>
+<p><span class="bold"><strong>Note:</strong></span> The local function name cannot be the name of an operator <code class="computeroutput">operator...</code> and it cannot be the same name of another local function declared within the same enclosing scope (but <code class="computeroutput">boost::overloaded_function</code> can be used to overload local functions, see Boost.Functional/OverloadedFunction and the <a class="link" href="boost_localfunction/advanced_topics.html" title="Advanced Topics"> Advanced Topics</a> section).</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/advanced_topics.html" title="Advanced Topics"> Advanced Topics</a> section, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code>, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_NAME_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_NAME_TPL">BOOST_LOCAL_FUNCTION_NAME_TPL</a></code>. </p>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2009-2012 Lorenzo
+ Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_ID_TPL.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_NAME_TPL.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_NAME_TPL.html b/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_NAME_TPL.html
new file mode 100644
index 000000000..9f06b6718
--- /dev/null
+++ b/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_NAME_TPL.html
@@ -0,0 +1,65 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Macro BOOST_LOCAL_FUNCTION_NAME_TPL</title>
+<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="up" href="reference.html#header.boost.local_function_hpp" title="Header &lt;boost/local_function.hpp&gt;">
+<link rel="prev" href="BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">
+<link rel="next" href="BOOST_LOCAL_FUNCTION_TYPEOF.html" title="Macro BOOST_LOCAL_FUNCTION_TYPEOF">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
+<td align="center"><a href="../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_NAME.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_TYPEOF.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="refentry">
+<a name="BOOST_LOCAL_FUNCTION_NAME_TPL"></a><div class="titlepage"></div>
+<div class="refnamediv">
+<h2><span class="refentrytitle">Macro BOOST_LOCAL_FUNCTION_NAME_TPL</span></h2>
+<p>BOOST_LOCAL_FUNCTION_NAME_TPL &#8212; This macro is used to end a local function declaration specifying its name within templates. </p>
+</div>
+<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
+<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="reference.html#header.boost.local_function_hpp" title="Header &lt;boost/local_function.hpp&gt;">boost/local_function.hpp</a>&gt;
+
+</span>BOOST_LOCAL_FUNCTION_NAME_TPL(name)</pre></div>
+<div class="refsect1">
+<a name="id883087"></a><h2>Description</h2>
+<p>This macro must be used instead of <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code> when declaring a local function within a template. A part from that, this macro has the exact same syntax a <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code> (see <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code> for more information): </p>
+<pre class="programlisting"><span class="special">{</span> <span class="comment">// Some declarative context within a template.</span>
+ <span class="special">...</span>
+ <span class="identifier">result_type</span> <span class="identifier">BOOST_LOCAL_FUNCTION_TPL</span><span class="special">(</span><span class="identifier">declarations</span><span class="special">)</span> <span class="special">{</span>
+ <span class="special">...</span> <span class="comment">// Body code.</span>
+ <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME_TPL</span><span class="special">(</span><span class="identifier">qualified_name</span><span class="special">)</span>
+ <span class="special">...</span>
+<span class="special">}</span>
+</pre>
+<p>Note that <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_TPL">BOOST_LOCAL_FUNCTION_TPL</a></code> must be used with this macro instead of <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code>.</p>
+<p><span class="bold"><strong>Note:</strong></span> C++03 does not allow to use <code class="computeroutput">typename</code> outside templates. This library internally manipulates types, these operations require <code class="computeroutput">typename</code> but only within templates. This macro is used to indicate to the library when the enclosing scope is a template so the library can correctly use <code class="computeroutput">typename</code>.</p>
+<p><span class="bold"><strong>See:</strong></span> <a class="link" href="boost_localfunction/tutorial.html" title="Tutorial"> Tutorial</a> section, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code>, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_TPL">BOOST_LOCAL_FUNCTION_TPL</a></code>. </p>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2009-2012 Lorenzo
+ Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_NAME.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_TYPEOF.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TPL.html b/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TPL.html
new file mode 100644
index 000000000..ec21f26e5
--- /dev/null
+++ b/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TPL.html
@@ -0,0 +1,66 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Macro BOOST_LOCAL_FUNCTION_TPL</title>
+<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="up" href="reference.html#header.boost.local_function_hpp" title="Header &lt;boost/local_function.hpp&gt;">
+<link rel="prev" href="BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">
+<link rel="next" href="BOOST_LOCAL_FUNCTION_ID.html" title="Macro BOOST_LOCAL_FUNCTION_ID">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
+<td align="center"><a href="../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_ID.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="refentry">
+<a name="BOOST_LOCAL_FUNCTION_TPL"></a><div class="titlepage"></div>
+<div class="refnamediv">
+<h2><span class="refentrytitle">Macro BOOST_LOCAL_FUNCTION_TPL</span></h2>
+<p>BOOST_LOCAL_FUNCTION_TPL &#8212; This macro is used to start a local function declaration within templates. </p>
+</div>
+<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
+<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="reference.html#header.boost.local_function_hpp" title="Header &lt;boost/local_function.hpp&gt;">boost/local_function.hpp</a>&gt;
+
+</span>BOOST_LOCAL_FUNCTION_TPL(declarations)</pre></div>
+<div class="refsect1">
+<a name="id881461"></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 a <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 within a template.</span>
+ <span class="special">...</span>
+ <span class="identifier">result_type</span> <span class="identifier">BOOST_LOCAL_FUNCTION_TPL</span><span class="special">(</span><span class="identifier">declarations</span><span class="special">)</span> <span class="special">{</span>
+ <span class="special">...</span> <span class="comment">// Body code.</span>
+ <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME_TPL</span><span class="special">(</span><span class="identifier">qualified_name</span><span class="special">)</span>
+ <span class="special">...</span>
+<span class="special">}</span>
+</pre>
+<p>Note that <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_NAME_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_NAME_TPL">BOOST_LOCAL_FUNCTION_NAME_TPL</a></code> must be used with this macro instead of <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code>.</p>
+<p>This macro cannot be portably expanded multiple times on the same line. In these cases, use the <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_ID_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_ID_TPL">BOOST_LOCAL_FUNCTION_ID_TPL</a></code> macro instead.</p>
+<p><span class="bold"><strong>Note:</strong></span> C++03 does not allow to use <code class="computeroutput">typename</code> outside templates. This library internally manipulates types, these operations require <code class="computeroutput">typename</code> but only within templates. This macro is used to indicate to the library when the enclosing scope is a template so the library can correctly use <code class="computeroutput">typename</code>.</p>
+<p><span class="bold"><strong>See:</strong></span> <a class="link" href="boost_localfunction/tutorial.html" title="Tutorial"> Tutorial</a> section, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code>, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_ID_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_ID_TPL">BOOST_LOCAL_FUNCTION_ID_TPL</a></code>, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_NAME_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_NAME_TPL">BOOST_LOCAL_FUNCTION_NAME_TPL</a></code>. </p>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2009-2012 Lorenzo
+ Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_ID.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TYPEOF.html b/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TYPEOF.html
new file mode 100644
index 000000000..da375bb58
--- /dev/null
+++ b/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TYPEOF.html
@@ -0,0 +1,78 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Macro BOOST_LOCAL_FUNCTION_TYPEOF</title>
+<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="up" href="reference.html#header.boost.local_function_hpp" title="Header &lt;boost/local_function.hpp&gt;">
+<link rel="prev" href="BOOST_LOCAL_FUNCTION_NAME_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_NAME_TPL">
+<link rel="next" href="BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
+<td align="center"><a href="../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_NAME_TPL.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="refentry">
+<a name="BOOST_LOCAL_FUNCTION_TYPEOF"></a><div class="titlepage"></div>
+<div class="refnamediv">
+<h2><span class="refentrytitle">Macro BOOST_LOCAL_FUNCTION_TYPEOF</span></h2>
+<p>BOOST_LOCAL_FUNCTION_TYPEOF &#8212; This macro expands to the type of the specified bound variable. </p>
+</div>
+<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
+<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="reference.html#header.boost.local_function_hpp" title="Header &lt;boost/local_function.hpp&gt;">boost/local_function.hpp</a>&gt;
+
+</span>BOOST_LOCAL_FUNCTION_TYPEOF(bound_variable_name)</pre></div>
+<div class="refsect1">
+<a name="id883286"></a><h2>Description</h2>
+<p>This macro can be used within the local functions body to refer to the bound variable types so to declare local variables, check concepts (using Boost.ConceptCheck), etc (see the <a class="link" href="boost_localfunction/advanced_topics.html" title="Advanced Topics"> Advanced Topics</a> section). This way the local function can be programmed entirely without explicitly specifying the bound variable types thus facilitating maintenance (e.g., if the type of a bound variable changes in the enclosing scope, the local function code does not have to change).</p>
+<p><span class="bold"><strong>Parameters:</strong></span> </p>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<tbody><tr>
+<td><span class="bold"><strong><code class="computeroutput">bound_variable_name</code></strong></span></td>
+<td>The name of one of the local function's bound variables. </td>
+</tr></tbody>
+</table></div>
+<p>
+</p>
+<p>The type returned by the macro is fully qualified in that it contains the extra constant and reference qualifiers when the specified variable is bound by constant and by reference. For example, if a variable named <code class="computeroutput">t</code> of type <code class="computeroutput">T</code> is: </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem"><p>Bound by value using <code class="computeroutput">bind t</code> then <code class="computeroutput">BOOST_LOCAL_FUNCTION_TYPEOF(t)</code> is <code class="computeroutput">T</code>. </p></li>
+<li class="listitem"><p>Bound by constant value using <code class="computeroutput">const bind t</code> then <code class="computeroutput">BOOST_LOCAL_FUNCTION_TYPEOF(t)</code> is <code class="computeroutput">const T</code>. </p></li>
+<li class="listitem"><p>Bound by reference using <code class="computeroutput">bind&amp; t</code> then <code class="computeroutput">BOOST_LOCAL_FUNCTION_TYPEOF(t)</code> is <code class="computeroutput">T&amp;</code>. </p></li>
+<li class="listitem"><p>Bound by constant reference using <code class="computeroutput">const bind&amp; t</code> then <code class="computeroutput">BOOST_LOCAL_FUNCTION_TYPEOF(t)</code> is <code class="computeroutput">const T&amp;</code>.</p></li>
+</ul></div>
+<p>
+This macro must be prefixed by <code class="computeroutput">typename</code> when used within templates.</p>
+<p><span class="bold"><strong>Note:</strong></span> It is best to use this macro instead of Boost.Typeof so to reduce the number of times Boost.Typeof is used to deduce types (see the <a class="link" href="boost_localfunction/advanced_topics.html" title="Advanced Topics"> Advanced Topics</a> section).</p>
+<p><span class="bold"><strong>See:</strong></span> <a class="link" href="boost_localfunction/advanced_topics.html" title="Advanced Topics"> Advanced Topics</a> section, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code>. </p>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2009-2012 Lorenzo
+ Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_NAME_TPL.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/libs/local_function/doc/html/boost_localfunction/acknowledgments.html b/libs/local_function/doc/html/boost_localfunction/acknowledgments.html
new file mode 100644
index 000000000..b4ee2923d
--- /dev/null
+++ b/libs/local_function/doc/html/boost_localfunction/acknowledgments.html
@@ -0,0 +1,102 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Acknowledgments</title>
+<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="prev" href="bibliography.html" title="Bibliography">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="bibliography.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a>
+</div>
+<div class="section boost_localfunction_acknowledgments">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_localfunction.acknowledgments"></a><a class="link" href="acknowledgments.html" title="Acknowledgments">Acknowledgments</a>
+</h2></div></div></div>
+<p>
+ This section aims to recognize the contributions of <span class="emphasis"><em>all</em></span>
+ the different people that participated directly or indirectly to the design
+ and development of this library.
+ </p>
+<p>
+ Many thanks to Steven Watanabe and Vicente Botet for suggesting to me to use
+ <a href="http://www.boost.org/libs/scope_exit" target="_top">Boost.ScopeExit</a> binding
+ to <a href="http://lists.boost.org/Archives/boost/2010/04/165149.php" target="_top">emulate
+ local functions</a>. Many thanks to Alexander Nasonov for clarifying how
+ <a href="http://www.boost.org/libs/scope_exit" target="_top">Boost.ScopeExit</a> binding
+ could be used to implement local functions and for some <a href="http://thread.gmane.org/gmane.comp.lib.boost.devel/168612" target="_top">early
+ work</a> in this direction.
+ </p>
+<p>
+ Many thanks to Gregory Crosswhite for using an early version of this library
+ in <a href="https://github.com/gcross/CodeSearch" target="_top">one of his projects</a>.
+ </p>
+<p>
+ Thanks to David Abrahams, Vicente Botet, et al. for suggesting to provide the
+ <a href="http://lists.boost.org/Archives/boost/2011/02/176712.php" target="_top">variadic
+ macro syntax</a> on compilers that support variadic macros.
+ </p>
+<p>
+ Thanks to Pierre Morcello for sharing some code that experimented with implementing
+ local functions using <a href="http://www.boost.org/libs/scope_exit" target="_top">Boost.ScopeExit</a>
+ binding (even if this library is not based on such a code).
+ </p>
+<p>
+ Thanks to John Bytheway for checking the authors' virtual functor technique
+ that originally allowed this library to pass local functions as template parameters.
+ </p>
+<p>
+ Thanks to Jeffrey Lee Hellrung for suggesting the use of the "keyword"
+ <code class="computeroutput"><span class="identifier">bind</span></code> to bind variables in scope
+ and for suggesting to use <code class="literal">bind(<span class="emphasis"><em>type</em></span>)</code>
+ to optionally specify the bound variable type. Thanks to Vicente Botet for
+ suggesting to provide a macro to expose the bound variable type to the public
+ API.
+ </p>
+<p>
+ Thanks to Steven Watanabe, Vicente Botet, Michael Caisse, Yechezkel Mett, Joel
+ de Guzman, Thomas Heller, et al. for helping with the <a class="link" href="alternatives.html" title="Annex: Alternatives">Alternatives</a>
+ section and with the profiling of the different alternatives.
+ </p>
+<p>
+ Many thanks to Jeffrey Lee Hellrung for managing the <a href="http://lists.boost.org/boost-announce/2011/12/0340.php" target="_top">Boost
+ review</a> of this library. Thanks also to all the people that submitted
+ a Boost review: Andrzej Krzemienski, Edward Diener, Gregory Crosswhite, John
+ Bytheway, Hartmut Kaiser, Krzysztof Czainski, Nat Lindon, Pierre Morcello,
+ Thomas Heller, and Vicente J. Botet. Thanks to everyone that commented on the
+ library during its Boost review.
+ </p>
+<p>
+ Finally, many thanks to the entire <a href="http://www.boost.org" target="_top">Boost</a>
+ community and <a href="http://lists.boost.org" target="_top">mailing list</a> for
+ providing valuable comments about this library and great insights on the C++
+ programming language.
+ </p>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2009-2012 Lorenzo
+ Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="bibliography.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a>
+</div>
+</body>
+</html>
diff --git a/libs/local_function/doc/html/boost_localfunction/advanced_topics.html b/libs/local_function/doc/html/boost_localfunction/advanced_topics.html
new file mode 100644
index 000000000..72d70b24d
--- /dev/null
+++ b/libs/local_function/doc/html/boost_localfunction/advanced_topics.html
@@ -0,0 +1,1410 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Advanced Topics</title>
+<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="prev" href="tutorial.html" title="Tutorial">
+<link rel="next" href="examples.html" title="Examples">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="tutorial.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="examples.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="section boost_localfunction_advanced_topics">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_localfunction.advanced_topics"></a><a class="link" href="advanced_topics.html" title="Advanced Topics">Advanced Topics</a>
+</h2></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"><a href="advanced_topics.html#boost_localfunction.advanced_topics.default_parameters">Default
+ Parameters</a></span></dt>
+<dt><span class="section"><a href="advanced_topics.html#boost_localfunction.advanced_topics.commas_and_symbols_in_macros">Commas
+ and Symbols in Macros</a></span></dt>
+<dt><span class="section"><a href="advanced_topics.html#boost_localfunction.advanced_topics.assignments_and_returns">Assignments
+ and Returns</a></span></dt>
+<dt><span class="section"><a href="advanced_topics.html#boost_localfunction.advanced_topics.nesting">Nesting</a></span></dt>
+<dt><span class="section"><a href="advanced_topics.html#boost_localfunction.advanced_topics.accessing_types__concepts__etc_">Accessing
+ Types (concepts, etc)</a></span></dt>
+<dt><span class="section"><a href="advanced_topics.html#boost_localfunction.advanced_topics.specifying_types__no_boost_typeof_">Specifying
+ Types (no Boost.Typeof)</a></span></dt>
+<dt><span class="section"><a href="advanced_topics.html#boost_localfunction.advanced_topics.inlining">Inlining</a></span></dt>
+<dt><span class="section"><a href="advanced_topics.html#boost_localfunction.advanced_topics.recursion">Recursion</a></span></dt>
+<dt><span class="section"><a href="advanced_topics.html#boost_localfunction.advanced_topics.overloading">Overloading</a></span></dt>
+<dt><span class="section"><a href="advanced_topics.html#boost_localfunction.advanced_topics.exception_specifications">Exception
+ Specifications</a></span></dt>
+<dt><span class="section"><a href="advanced_topics.html#boost_localfunction.advanced_topics.storage_classifiers">Storage
+ Classifiers</a></span></dt>
+<dt><span class="section"><a href="advanced_topics.html#boost_localfunction.advanced_topics.same_line_expansions">Same
+ Line Expansions</a></span></dt>
+<dt><span class="section"><a href="advanced_topics.html#boost_localfunction.advanced_topics.limitations__operators__etc_">Limitations
+ (operators, etc)</a></span></dt>
+</dl></div>
+<p>
+ This section illustrates advanced usage of this library. At the bottom there
+ is also a list of known limitations of this library.
+ </p>
+<div class="section boost_localfunction_advanced_topics_default_parameters">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.advanced_topics.default_parameters"></a><a class="link" href="advanced_topics.html#boost_localfunction.advanced_topics.default_parameters" title="Default Parameters">Default
+ Parameters</a>
+</h3></div></div></div>
+<p>
+ This library allows to specify default values for the local function parameters.
+ However, the usual C++ syntax for default parameters that uses the assignment
+ symbol <code class="computeroutput"><span class="special">=</span></code> cannot be used. <sup>[<a name="boost_localfunction.advanced_topics.default_parameters.f0" href="#ftn.boost_localfunction.advanced_topics.default_parameters.f0" class="footnote">17</a>]</sup> The keyword <code class="computeroutput"><span class="keyword">default</span></code>
+ is used instead:
+ </p>
+<pre class="programlisting"><code class="literal"><span class="emphasis"><em>parameter-type parameter-name</em></span></code><span class="special">,</span> <span class="keyword">default</span> <code class="literal"><span class="emphasis"><em>parameter-default-value</em></span></code><span class="special">,</span> <span class="special">...</span>
+</pre>
+<p>
+ For example, let's program a local function <code class="computeroutput"><span class="identifier">add</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span>
+ <span class="identifier">y</span><span class="special">)</span></code>
+ where the second parameter <code class="computeroutput"><span class="identifier">y</span></code>
+ is optional and has a default value of <code class="computeroutput"><span class="number">2</span></code>
+ (see also <a href="../../../test/add_default.cpp" target="_top"><code class="literal">add_default.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">y</span><span class="special">,</span> <span class="keyword">default</span> <span class="number">2</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Default parameter.</span>
+ <span class="keyword">return</span> <span class="identifier">x</span> <span class="special">+</span> <span class="identifier">y</span><span class="special">;</span>
+<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">add</span><span class="special">)</span>
+
+<span class="identifier">BOOST_TEST</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="special">==</span> <span class="number">3</span><span class="special">);</span>
+</pre>
+<p>
+ </p>
+<p>
+ Programmers can define a <code class="computeroutput"><span class="identifier">WITH_DEFAULT</span></code>
+ macro similar to the following if they think it improves readability over
+ the above syntax (see also <a href="../../../test/add_with_default.cpp" target="_top"><code class="literal">add_with_default.cpp</code></a>):
+ <sup>[<a name="boost_localfunction.advanced_topics.default_parameters.f1" href="#ftn.boost_localfunction.advanced_topics.default_parameters.f1" class="footnote">18</a>]</sup>
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="preprocessor">#define</span> <span class="identifier">WITH_DEFAULT</span> <span class="special">,</span> <span class="keyword">default</span>
+</pre>
+<p>
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">y</span> <span class="identifier">WITH_DEFAULT</span> <span class="number">2</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Default.</span>
+ <span class="keyword">return</span> <span class="identifier">x</span> <span class="special">+</span> <span class="identifier">y</span><span class="special">;</span>
+<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">add</span><span class="special">)</span>
+
+<span class="identifier">BOOST_TEST</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="special">==</span> <span class="number">3</span><span class="special">);</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="section boost_localfunction_advanced_topics_commas_and_symbols_in_macros">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.advanced_topics.commas_and_symbols_in_macros"></a><a class="link" href="advanced_topics.html#boost_localfunction.advanced_topics.commas_and_symbols_in_macros" title="Commas and Symbols in Macros">Commas
+ and Symbols in Macros</a>
+</h3></div></div></div>
+<p>
+ The C++ preprocessor does not allow commas <code class="computeroutput"><span class="special">,</span></code>
+ within macro parameters unless they are wrapped by round parenthesis <code class="computeroutput"><span class="special">()</span></code> (see the <a href="http://www.boost.org/libs/utility/identity_type" target="_top">Boost.Utility/IdentityType</a>
+ documentation for details). Therefore, using commas within local function
+ parameters and bindings will generate (cryptic) preprocessor errors unless
+ they are wrapped with an extra set of round parenthesis <code class="computeroutput"><span class="special">()</span></code>
+ as explained here.
+ </p>
+<div class="note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ Also macro parameters with commas wrapped by angular parenthesis <code class="computeroutput"><span class="special">&lt;&gt;</span></code> (templates, etc) or square parenthesis
+ <code class="computeroutput"><span class="special">[]</span></code> (multidimensional array
+ access, etc) need to be wrapped by the extra round parenthesis <code class="computeroutput"><span class="special">()</span></code> as explained here (this is because the
+ preprocessor only recognizes the round parenthesis and it does not recognize
+ angular, square, or any other type of parenthesis). However, macro parameters
+ with commas which are already wrapped by round parenthesis <code class="computeroutput"><span class="special">()</span></code> are fine (function calls, some value
+ expressions, etc).
+ </p></td></tr>
+</table></div>
+<p>
+ In addition, local function parameter types cannot start with non-alphanumeric
+ symbols (alphanumeric symbols are <code class="computeroutput"><span class="identifier">A</span><span class="special">-</span><span class="identifier">Z</span></code>, <code class="computeroutput"><span class="identifier">a</span><span class="special">-</span><span class="identifier">z</span></code>,
+ and <code class="computeroutput"><span class="number">0</span><span class="special">-</span><span class="number">9</span></code>). <sup>[<a name="boost_localfunction.advanced_topics.commas_and_symbols_in_macros.f0" href="#ftn.boost_localfunction.advanced_topics.commas_and_symbols_in_macros.f0" class="footnote">19</a>]</sup> The library will generate (cryptic) preprocessor errors if a
+ parameter type starts with a non-alphanumeric symbol.
+ </p>
+<p>
+ Let's consider the following example:
+ </p>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span>
+ <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">size_t</span><span class="special">&gt;&amp;</span> <span class="identifier">m</span><span class="special">,</span> <span class="comment">// (1) Error.</span>
+ <span class="special">::</span><span class="identifier">sign_t</span> <span class="identifier">sign</span><span class="special">,</span> <span class="comment">// (2) Error.</span>
+ <span class="keyword">const</span> <span class="identifier">size_t</span><span class="special">&amp;</span> <span class="identifier">factor</span><span class="special">,</span>
+ <span class="keyword">default</span> <span class="identifier">key_sizeof</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">value</span><span class="special">,</span> <span class="comment">// (3) Error.</span>
+ <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&amp;</span> <span class="identifier">separator</span><span class="special">,</span> <span class="keyword">default</span> <span class="identifier">cat</span><span class="special">(</span><span class="string">":"</span><span class="special">,</span> <span class="string">" "</span><span class="special">)</span> <span class="comment">// (4) OK.</span>
+<span class="special">)</span> <span class="special">{</span>
+ <span class="special">...</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>
+</pre>
+<p>
+ <span class="bold"><strong>(1)</strong></span> The parameter type <code class="computeroutput"><span class="keyword">const</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">size_t</span><span class="special">&gt;&amp;</span></code> contains a comma <code class="computeroutput"><span class="special">,</span></code>
+ after the first template parameter <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code>.
+ This comma is not wrapped by any round parenthesis <code class="computeroutput"><span class="special">()</span></code>
+ thus it will cause a preprocessor error. <sup>[<a name="boost_localfunction.advanced_topics.commas_and_symbols_in_macros.f1" href="#ftn.boost_localfunction.advanced_topics.commas_and_symbols_in_macros.f1" class="footnote">20</a>]</sup> The <a href="http://www.boost.org/libs/utility/identity_type" target="_top">Boost.Utility/IdentityType</a>
+ macro <code class="computeroutput"><span class="identifier">BOOST_IDENTITY_TYPE</span><span class="special">((</span></code><code class="literal"><span class="emphasis"><em>type-with-commas</em></span></code><code class="computeroutput"><span class="special">))</span></code> defined in the <code class="literal">boost/utility/identity_type.hpp</code>
+ header can be used to wrap a type within extra parenthesis <code class="computeroutput"><span class="special">()</span></code> so to overcome this problem:
+ </p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">utility</span><span class="special">/</span><span class="identifier">identity_type</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span>
+ <span class="identifier">BOOST_IDENTITY_TYPE</span><span class="special">((</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">size_t</span><span class="special">&gt;&amp;))</span> <span class="identifier">m</span><span class="special">,</span> <span class="comment">// OK.</span>
+ <span class="special">...</span>
+<span class="special">)</span> <span class="special">{</span>
+ <span class="special">...</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>
+</pre>
+<p>
+ This macro expands to an expression that evaluates (at compile-time) exactly
+ to the specified type (furthermore, this macro does not use variadic macros
+ so it works on any <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/standards" target="_top">C++03</a>
+ compiler). Note that a total of two set of parenthesis <code class="computeroutput"><span class="special">()</span></code>
+ are needed: The parenthesis to invoke the <code class="computeroutput"><span class="identifier">BOOST_IDENTITY_TYPE</span><span class="special">(...)</span></code> macro plus the parenthesis to wrap the
+ type expression (and therefore any comma <code class="computeroutput"><span class="special">,</span></code>
+ that it contains) passed as parameter to the <code class="computeroutput"><span class="identifier">BOOST_IDENTITY_TYPE</span><span class="special">((...))</span></code> macro. Finally, the <code class="computeroutput"><span class="identifier">BOOST_IDENTITY_TYPE</span></code> macro must be prefixed
+ by the <code class="computeroutput"><span class="keyword">typename</span></code> keyword <code class="computeroutput"><span class="keyword">typename</span> <span class="identifier">BOOST_IDENTITY_TYPE</span><span class="special">(</span></code><code class="literal"><span class="emphasis"><em>parenthesized-type</em></span></code><code class="computeroutput"><span class="special">)</span></code> when used together with the <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_TPL">BOOST_LOCAL_FUNCTION_TPL</a></code>
+ macro within templates.
+ </p>
+<div class="note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ Often, there might be better ways to overcome this limitation that lead
+ to code which is more readable than the one using the <code class="computeroutput"><span class="identifier">BOOST_IDENTITY_TYPE</span></code>
+ macro.
+ </p></td></tr>
+</table></div>
+<p>
+ For example, in this case a <code class="computeroutput"><span class="keyword">typedef</span></code>
+ from the enclosing scope could have been used to obtain the following valid
+ and perhaps more readable code:
+ </p>
+<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">size_t</span><span class="special">&gt;</span> <span class="identifier">map_type</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">map_type</span><span class="special">&amp;</span> <span class="identifier">m</span><span class="special">,</span> <span class="comment">// OK (and more readable).</span>
+ <span class="special">...</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>
+</pre>
+<p>
+ <span class="bold"><strong>(2)</strong></span> The parameter type <code class="computeroutput"><span class="special">::</span><span class="identifier">sign_t</span></code> starts with the non-alphanumeric
+ symbols <code class="computeroutput"><span class="special">::</span></code> thus it will generate
+ preprocessor errors if used as a local function parameter type. The <code class="computeroutput"><span class="identifier">BOOST_IDENTITY_TYPE</span></code> macro can also be used
+ to overcome this issue:
+ </p>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span>
+ <span class="special">...</span>
+ <span class="identifier">BOOST_IDENTITY_TYPE</span><span class="special">((::</span><span class="identifier">sign_t</span><span class="special">))</span> <span class="identifier">sign</span><span class="special">,</span> <span class="comment">// OK.</span>
+ <span class="special">...</span>
+<span class="special">)</span> <span class="special">{</span>
+ <span class="special">...</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>
+</pre>
+<div class="note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ Often, there might be better ways to overcome this limitation that lead
+ to code which is more readable than the one using the <code class="computeroutput"><span class="identifier">BOOST_IDENTITY_TYPE</span></code>
+ macro.
+ </p></td></tr>
+</table></div>
+<p>
+ For example, in this case the symbols <code class="computeroutput"><span class="special">::</span></code>
+ could have been simply dropped to obtain the following valid and perhaps
+ more readable code:
+ </p>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span>
+ <span class="special">...</span>
+ <span class="identifier">sign_t</span> <span class="identifier">sign</span><span class="special">,</span> <span class="comment">// OK (and more readable).</span>
+ <span class="special">...</span>
+<span class="special">)</span> <span class="special">{</span>
+ <span class="special">...</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>
+</pre>
+<p>
+ <span class="bold"><strong>(3)</strong></span> The default parameter value <code class="computeroutput"><span class="identifier">key_sizeof</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">value</span></code>
+ contains a comma <code class="computeroutput"><span class="special">,</span></code> after the
+ first template parameter <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code>.
+ Again, this comma is not wrapped by any parenthesis <code class="computeroutput"><span class="special">()</span></code>
+ so it will cause a preprocessor error. Because this is a value expression
+ (and not a type expression), it can simply be wrapped within an extra set
+ of round parenthesis <code class="computeroutput"><span class="special">()</span></code>:
+ </p>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span>
+ <span class="special">...</span>
+ <span class="keyword">const</span> <span class="identifier">size_t</span><span class="special">&amp;</span> <span class="identifier">factor</span><span class="special">,</span>
+ <span class="keyword">default</span> <span class="special">(</span><span class="identifier">key_sizeof</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">value</span><span class="special">),</span> <span class="comment">// OK.</span>
+ <span class="special">...</span>
+<span class="special">)</span> <span class="special">{</span>
+ <span class="special">...</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>
+</pre>
+<p>
+ <span class="bold"><strong>(4)</strong></span> The default parameter value <code class="computeroutput"><span class="identifier">cat</span><span class="special">(</span><span class="string">":"</span><span class="special">,</span> <span class="string">" "</span><span class="special">)</span></code> is instead fine because it contains a comma
+ <code class="computeroutput"><span class="special">,</span></code> which is already wrapped by
+ the parenthesis <code class="computeroutput"><span class="special">()</span></code> of the function
+ call <code class="computeroutput"><span class="identifier">cat</span><span class="special">(...)</span></code>.
+ </p>
+<p>
+ Consider the following complete example (see also <a href="../../../test/macro_commas.cpp" target="_top"><code class="literal">macro_commas.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span>
+ <span class="identifier">BOOST_IDENTITY_TYPE</span><span class="special">((</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">size_t</span><span class="special">&gt;&amp;))</span> <span class="identifier">m</span><span class="special">,</span>
+ <span class="identifier">BOOST_IDENTITY_TYPE</span><span class="special">((::</span><span class="identifier">sign_t</span><span class="special">))</span> <span class="identifier">sign</span><span class="special">,</span>
+ <span class="keyword">const</span> <span class="identifier">size_t</span><span class="special">&amp;</span> <span class="identifier">factor</span><span class="special">,</span>
+ <span class="keyword">default</span> <span class="special">(</span><span class="identifier">key_sizeof</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">value</span><span class="special">),</span>
+ <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&amp;</span> <span class="identifier">separator</span><span class="special">,</span> <span class="keyword">default</span> <span class="identifier">cat</span><span class="special">(</span><span class="string">":"</span><span class="special">,</span> <span class="string">" "</span><span class="special">)</span>
+<span class="special">)</span> <span class="special">{</span>
+ <span class="comment">// Do something...</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>
+</pre>
+<p>
+ </p>
+</div>
+<div class="section boost_localfunction_advanced_topics_assignments_and_returns">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.advanced_topics.assignments_and_returns"></a><a class="link" href="advanced_topics.html#boost_localfunction.advanced_topics.assignments_and_returns" title="Assignments and Returns">Assignments
+ and Returns</a>
+</h3></div></div></div>
+<p>
+ Local functions are function objects so it is possible to assign them to
+ other functors like <a href="http://www.boost.org/libs/function" target="_top">Boost.Function</a>'s
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span></code> in order to store the local function
+ into a variable, pass it as a parameter to another function, or return it
+ from the enclosing function.
+ </p>
+<p>
+ For example (see also <a href="../../../test/return_assign.cpp" target="_top"><code class="literal">return_assign.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">call1</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span><span class="keyword">int</span> <span class="special">(</span><span class="keyword">int</span><span class="special">)</span> <span class="special">&gt;</span> <span class="identifier">f</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">f</span><span class="special">(</span><span class="number">1</span><span class="special">)</span> <span class="special">==</span> <span class="number">5</span><span class="special">);</span> <span class="special">}</span>
+<span class="keyword">void</span> <span class="identifier">call0</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span><span class="keyword">int</span> <span class="special">(</span><span class="keyword">void</span><span class="special">)&gt;</span> <span class="identifier">f</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">f</span><span class="special">()</span> <span class="special">==</span> <span class="number">5</span><span class="special">);</span> <span class="special">}</span>
+
+<span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span><span class="keyword">int</span> <span class="special">(</span><span class="keyword">int</span><span class="special">,</span> <span class="keyword">int</span><span class="special">)&gt;</span> <span class="identifier">linear</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">int</span><span class="special">&amp;</span> <span class="identifier">slope</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">int</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">slope</span><span class="special">,</span>
+ <span class="keyword">int</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">default</span> <span class="number">1</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">y</span><span class="special">,</span> <span class="keyword">default</span> <span class="number">2</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">return</span> <span class="identifier">x</span> <span class="special">+</span> <span class="identifier">slope</span> <span class="special">*</span> <span class="identifier">y</span><span class="special">;</span>
+ <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">lin</span><span class="special">)</span>
+
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span><span class="keyword">int</span> <span class="special">(</span><span class="keyword">int</span><span class="special">,</span> <span class="keyword">int</span><span class="special">)&gt;</span> <span class="identifier">f</span> <span class="special">=</span> <span class="identifier">lin</span><span class="special">;</span> <span class="comment">// Assign to local variable.</span>
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">f</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="number">2</span><span class="special">)</span> <span class="special">==</span> <span class="number">5</span><span class="special">);</span>
+
+ <span class="identifier">call1</span><span class="special">(</span><span class="identifier">lin</span><span class="special">);</span> <span class="comment">// Pass to other functions.</span>
+ <span class="identifier">call0</span><span class="special">(</span><span class="identifier">lin</span><span class="special">);</span>
+
+ <span class="keyword">return</span> <span class="identifier">lin</span><span class="special">;</span> <span class="comment">// Return.</span>
+<span class="special">}</span>
+
+<span class="keyword">void</span> <span class="identifier">call</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span><span class="keyword">int</span> <span class="special">(</span><span class="keyword">int</span><span class="special">,</span> <span class="keyword">int</span><span class="special">)&gt;</span> <span class="identifier">f</span> <span class="special">=</span> <span class="identifier">linear</span><span class="special">(</span><span class="number">2</span><span class="special">);</span>
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">f</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="number">2</span><span class="special">)</span> <span class="special">==</span> <span class="number">5</span><span class="special">);</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+<div class="warning"><table border="0" summary="Warning">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../doc/src/images/warning.png"></td>
+<th align="left">Warning</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ As with <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a>, programmers are responsible to ensure that bound
+ variables are valid in any scope where the local function object is called.
+ Returning and calling a local function outside its declaration scope will
+ lead to undefined behaviour if any of the bound variable is no longer valid
+ in the scope where the local function is called (see the <a class="link" href="examples.html" title="Examples">Examples</a>
+ section for more examples on the extra care needed when returning a local
+ function as a closure). It is always safe instead to call a local function
+ within its enclosing scope.
+ </p></td></tr>
+</table></div>
+<p>
+ In addition, a local function can bind and call other local functions. Local
+ functions should always be bound by constant reference <code class="computeroutput"><span class="keyword">const</span>
+ <span class="identifier">bind</span><span class="special">&amp;</span></code>
+ to avoid unnecessary copies. For example, the following local function <code class="computeroutput"><span class="identifier">inc_sum</span></code> binds the local function <code class="computeroutput"><span class="identifier">inc</span></code> so <code class="computeroutput"><span class="identifier">inc_sum</span></code>
+ can call <code class="computeroutput"><span class="identifier">inc</span></code> (see aslo <a href="../../../test/transform.cpp" target="_top"><code class="literal">transform.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">offset</span> <span class="special">=</span> <span class="number">5</span><span class="special">;</span>
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">v</span><span class="special">;</span>
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">w</span><span class="special">;</span>
+
+<span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">1</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">v</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">i</span> <span class="special">*</span> <span class="number">10</span><span class="special">);</span>
+<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">v</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="special">==</span> <span class="number">10</span><span class="special">);</span> <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">v</span><span class="special">[</span><span class="number">1</span><span class="special">]</span> <span class="special">==</span> <span class="number">20</span><span class="special">);</span>
+<span class="identifier">w</span><span class="special">.</span><span class="identifier">resize</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">size</span><span class="special">());</span>
+
+<span class="keyword">int</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">offset</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">i</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">return</span> <span class="special">++</span><span class="identifier">i</span> <span class="special">+</span> <span class="identifier">offset</span><span class="special">;</span>
+<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">inc</span><span class="special">)</span>
+
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">transform</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">w</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">inc</span><span class="special">);</span>
+<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">w</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="special">==</span> <span class="number">16</span><span class="special">);</span> <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">w</span><span class="special">[</span><span class="number">1</span><span class="special">]</span> <span class="special">==</span> <span class="number">26</span><span class="special">);</span>
+
+<span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="identifier">bind</span><span class="special">&amp;</span> <span class="identifier">inc</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">i</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">j</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">return</span> <span class="identifier">inc</span><span class="special">(</span><span class="identifier">i</span> <span class="special">+</span> <span class="identifier">j</span><span class="special">);</span> <span class="comment">// Call the other bound local function.</span>
+<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">inc_sum</span><span class="special">)</span>
+
+<span class="identifier">offset</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">transform</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">w</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">inc_sum</span><span class="special">);</span>
+<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">v</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="special">==</span> <span class="number">27</span><span class="special">);</span> <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">v</span><span class="special">[</span><span class="number">1</span><span class="special">]</span> <span class="special">==</span> <span class="number">47</span><span class="special">);</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="section boost_localfunction_advanced_topics_nesting">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.advanced_topics.nesting"></a><a class="link" href="advanced_topics.html#boost_localfunction.advanced_topics.nesting" title="Nesting">Nesting</a>
+</h3></div></div></div>
+<p>
+ It is possible to nest local functions into one another. For example (see
+ also <a href="../../../test/nesting.cpp" target="_top"><code class="literal">nesting.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">x</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
+
+<span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</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="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</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">// Nested.</span>
+ <span class="identifier">x</span><span class="special">++;</span>
+ <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">g</span><span class="special">)</span>
+
+ <span class="identifier">x</span><span class="special">--;</span>
+ <span class="identifier">g</span><span class="special">();</span> <span class="comment">// Nested local function call.</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>
+</pre>
+<p>
+ </p>
+</div>
+<div class="section boost_localfunction_advanced_topics_accessing_types__concepts__etc_">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.advanced_topics.accessing_types__concepts__etc_"></a><a class="link" href="advanced_topics.html#boost_localfunction.advanced_topics.accessing_types__concepts__etc_" title="Accessing Types (concepts, etc)">Accessing
+ Types (concepts, etc)</a>
+</h3></div></div></div>
+<p>
+ This library never requires to explicitly specify the type of bound variables
+ (e.g., this reduces maintenance because the local function declaration and
+ definition do not have to change even if the bound variable types change
+ as long as the semantics of the local function remain valid). From within
+ local functions, programmers can access the type of a bound variable using
+ the following macro:
+ </p>
+<pre class="programlisting"><span class="identifier">BOOST_LOCAL_FUNCTION_TYPEOF</span><span class="special">(</span><span class="emphasis"><em>bound-variable-name</em></span><span class="special">)</span>
+</pre>
+<p>
+ The <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_TYPEOF.html" title="Macro BOOST_LOCAL_FUNCTION_TYPEOF">BOOST_LOCAL_FUNCTION_TYPEOF</a></code>
+ macro expands to a type expression that evaluates (at compile-time) to the
+ fully qualified type of the bound variable with the specified name. This
+ type expression is fully qualified in the sense that it will be constant
+ if the variable is bound by constant <code class="computeroutput"><span class="keyword">const</span>
+ <span class="identifier">bind</span><span class="special">[&amp;]</span></code>
+ and it will also be a reference if the variable is bound by reference <code class="computeroutput"><span class="special">[</span><span class="keyword">const</span><span class="special">]</span>
+ <span class="identifier">bind</span><span class="special">&amp;</span></code>
+ (if needed, programmers can remove the <code class="computeroutput"><span class="keyword">const</span></code>
+ and <code class="computeroutput"><span class="special">&amp;</span></code> qualifiers using
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">remove_const</span></code> and <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">remove_reference</span></code>,
+ see <a href="http://www.boost.org/libs/type_traits" target="_top">Boost.TypeTraits</a>).
+ </p>
+<p>
+ The deduced bound type can be used within the body to check concepts, declare
+ local variables, etc. For example (see also <a href="../../../test/typeof.cpp" target="_top"><code class="literal">typeof.cpp</code></a>
+ and <a href="../../../test/addable.hpp" target="_top"><code class="literal">addable.hpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><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">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="comment">// Type-of for concept checking.</span>
+ <span class="identifier">BOOST_CONCEPT_ASSERT</span><span class="special">((</span><span class="identifier">Addable</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">remove_reference</span><span class="special">&lt;</span>
+ <span class="identifier">BOOST_LOCAL_FUNCTION_TYPEOF</span><span class="special">(</span><span class="identifier">sum</span><span class="special">)&gt;::</span><span class="identifier">type</span><span class="special">&gt;));</span>
+ <span class="comment">// Type-of for declarations.</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">remove_reference</span><span class="special">&lt;</span><span class="identifier">BOOST_LOCAL_FUNCTION_TYPEOF</span><span class="special">(</span>
+ <span class="identifier">factor</span><span class="special">)&gt;::</span><span class="identifier">type</span> <span class="identifier">mult</span> <span class="special">=</span> <span class="identifier">factor</span> <span class="special">*</span> <span class="identifier">num</span><span class="special">;</span>
+ <span class="identifier">sum</span> <span class="special">+=</span> <span class="identifier">mult</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">6</span><span class="special">);</span>
+</pre>
+<p>
+ </p>
+<p>
+ Within templates, <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_TYPEOF.html" title="Macro BOOST_LOCAL_FUNCTION_TYPEOF">BOOST_LOCAL_FUNCTION_TYPEOF</a></code>
+ should not be prefixed by the <code class="computeroutput"><span class="keyword">typename</span></code>
+ keyword but eventual type manipulations need the <code class="computeroutput"><span class="keyword">typename</span></code>
+ prefix as usual (see also <a href="../../../test/typeof_template.cpp" target="_top"><code class="literal">typeof_template.cpp</code></a>
+ and <a href="../../../test/addable.hpp" target="_top"><code class="literal">addable.hpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">&gt;</span>
+<span class="identifier">T</span> <span class="identifier">calculate</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">T</span><span class="special">&amp;</span> <span class="identifier">factor</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">T</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
+
+ <span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION_TPL</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="identifier">T</span> <span class="identifier">num</span><span class="special">)</span> <span class="special">{</span>
+ <span class="comment">// Local function `TYPEOF` does not need `typename`.</span>
+ <span class="identifier">BOOST_CONCEPT_ASSERT</span><span class="special">((</span><span class="identifier">Addable</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">remove_reference</span><span class="special">&lt;</span>
+ <span class="identifier">BOOST_LOCAL_FUNCTION_TYPEOF</span><span class="special">(</span><span class="identifier">sum</span><span class="special">)&gt;::</span><span class="identifier">type</span><span class="special">&gt;));</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_TPL</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">6</span><span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">sum</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ In this context, it is best to use the <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_TYPEOF.html" title="Macro BOOST_LOCAL_FUNCTION_TYPEOF">BOOST_LOCAL_FUNCTION_TYPEOF</a></code>
+ macro instead of using <a href="http://www.boost.org/libs/typeof" target="_top">Boost.Typeof</a>
+ to reduce the number of times that <a href="http://www.boost.org/libs/typeof" target="_top">Boost.Typeof</a>
+ is invoked (either the library already internally used <a href="http://www.boost.org/libs/typeof" target="_top">Boost.Typeof</a>
+ once, in which case using this macro will not use <a href="http://www.boost.org/libs/typeof" target="_top">Boost.Typeof</a>
+ again, or the bound variable type is explicitly specified by programmers
+ as shown be below, in which case using this macro will not use <a href="http://www.boost.org/libs/typeof" target="_top">Boost.Typeof</a>
+ at all).
+ </p>
+<p>
+ Furthermore, within the local function body it possible to access the result
+ type using <code class="computeroutput"><span class="identifier">result_type</span></code>, the
+ type of the first parameter using <code class="computeroutput"><span class="identifier">arg1_type</span></code>,
+ the type of the second parameter using <code class="computeroutput"><span class="identifier">arg2_type</span></code>,
+ etc. <sup>[<a name="boost_localfunction.advanced_topics.accessing_types__concepts__etc_.f0" href="#ftn.boost_localfunction.advanced_topics.accessing_types__concepts__etc_.f0" class="footnote">21</a>]</sup>
+ </p>
+</div>
+<div class="section boost_localfunction_advanced_topics_specifying_types__no_boost_typeof_">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.advanced_topics.specifying_types__no_boost_typeof_"></a><a class="link" href="advanced_topics.html#boost_localfunction.advanced_topics.specifying_types__no_boost_typeof_" title="Specifying Types (no Boost.Typeof)">Specifying
+ Types (no Boost.Typeof)</a>
+</h3></div></div></div>
+<p>
+ While not required, it is possible to explicitly specify the type of bound
+ variables so the library will not internally use <a href="http://www.boost.org/libs/typeof" target="_top">Boost.Typeof</a>
+ to automatically deduce the types. When specified, the bound variable type
+ must follow the <code class="computeroutput"><span class="identifier">bind</span></code> "keyword"
+ and it must be wrapped within round parenthesis <code class="computeroutput"><span class="special">()</span></code>:
+ </p>
+<pre class="programlisting"><span class="identifier">bind</span><span class="special">(</span><span class="emphasis"><em>variable-type</em></span><span class="special">)</span> <span class="emphasis"><em>variable-name</em></span> <span class="comment">// Bind by value with explicit type.</span>
+<span class="identifier">bind</span><span class="special">(</span><span class="emphasis"><em>variable-type</em></span><span class="special">)&amp;</span> <span class="emphasis"><em>variable-name</em></span> <span class="comment">// Bind by reference with explicit type.</span>
+<span class="keyword">const</span> <span class="identifier">bind</span><span class="special">(</span><span class="emphasis"><em>variable-type</em></span><span class="special">)</span> <span class="emphasis"><em>variable-name</em></span> <span class="comment">// Bind by constant value with explicit type.</span>
+<span class="keyword">const</span> <span class="identifier">bind</span><span class="special">(</span><span class="emphasis"><em>variable-type</em></span><span class="special">)&amp;</span> <span class="emphasis"><em>variable-name</em></span> <span class="comment">// Bind by constant reference with explicit type.</span>
+<span class="identifier">bind</span><span class="special">(</span><span class="emphasis"><em>class-type</em></span><span class="special">*)</span> <span class="identifier">this_</span> <span class="comment">// Bind object `this` with explicit type.</span>
+<span class="keyword">const</span> <span class="identifier">bind</span><span class="special">(</span><span class="emphasis"><em>class-type</em></span><span class="special">*)</span> <span class="identifier">this_</span> <span class="comment">// Bind object `this` by constant with explicit type.</span>
+</pre>
+<p>
+ Note that within the local function body it is always possible to abstract
+ the access to the type of a bound variable using <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_TYPEOF.html" title="Macro BOOST_LOCAL_FUNCTION_TYPEOF">BOOST_LOCAL_FUNCTION_TYPEOF</a></code>
+ (even when the bound variable type is explicitly specified in the local function
+ declaration).
+ </p>
+<p>
+ The library also uses <a href="http://www.boost.org/libs/typeof" target="_top">Boost.Typeof</a>
+ to determine the local function result type (because this type is specified
+ outside the <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code>
+ macro). Thus it is also possible to specify the local function result type
+ as one of the <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code>
+ macro parameters prefixing it by <code class="computeroutput"><span class="keyword">return</span></code>
+ so the library will not use <a href="http://www.boost.org/libs/typeof" target="_top">Boost.Typeof</a>
+ to deduce the result type:
+ </p>
+<pre class="programlisting"><span class="identifier">BOOST_LOCAL_FUNCTION_TYPE</span><span class="special">(</span><span class="keyword">return</span> <code class="literal"><span class="emphasis"><em>result-type</em></span></code><span class="special">,</span> <span class="special">...)</span>
+</pre>
+<p>
+ Note that the result type must be specified only once either before the macro
+ (without the <code class="computeroutput"><span class="keyword">return</span></code> prefix)
+ or as one of the macro parameters (with the <code class="computeroutput"><span class="keyword">return</span></code>
+ prefix). As always, the result type can be <code class="computeroutput"><span class="keyword">void</span></code>
+ to declare a function that returns nothing (so <code class="computeroutput"><span class="keyword">return</span>
+ <span class="keyword">void</span></code> is allowed when the result type
+ is specified as one of the macro parameters).
+ </p>
+<p>
+ The following example specifies all bound variables and result types (see
+ also <a href="../../../test/add_typed.cpp" target="_top"><code class="literal">add_typed.cpp</code></a>):
+ <sup>[<a name="boost_localfunction.advanced_topics.specifying_types__no_boost_typeof_.f0" href="#ftn.boost_localfunction.advanced_topics.specifying_types__no_boost_typeof_.f0" class="footnote">22</a>]</sup>
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">adder</span> <span class="special">{</span>
+ <span class="identifier">adder</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">:</span> <span class="identifier">sum_</span><span class="special">(</span><span class="number">0</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="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;&amp;</span> <span class="identifier">nums</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">int</span><span class="special">&amp;</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">)</span> <span class="special">{</span>
+ <span class="comment">// Explicitly specify bound variable and return types (no type-of).</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">(</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="identifier">bind</span><span class="special">(</span><span class="identifier">adder</span><span class="special">*)</span> <span class="identifier">this_</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">num</span><span class="special">,</span> <span class="keyword">return</span> <span class="keyword">int</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">return</span> <span class="identifier">this_</span><span class="special">-&gt;</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">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">begin</span><span class="special">(),</span> <span class="identifier">nums</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">add</span><span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">sum_</span><span class="special">;</span>
+ <span class="special">}</span>
+
+<span class="keyword">private</span><span class="special">:</span>
+ <span class="keyword">int</span> <span class="identifier">sum_</span><span class="special">;</span>
+<span class="special">};</span>
+</pre>
+<p>
+ </p>
+<p>
+ Unless necessary, it is recommended to not specify the bound variable and
+ result types. Let the library deduce these types so the local function syntax
+ will be more concise and the local function declaration will not have to
+ change if a bound variable type changes (reducing maintenance).
+ </p>
+<div class="note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ When all bound variable and result types are explicitly specified, the
+ library implementation will not use <a href="http://www.boost.org/libs/typeof" target="_top">Boost.Typeof</a>.
+ </p></td></tr>
+</table></div>
+</div>
+<div class="section boost_localfunction_advanced_topics_inlining">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.advanced_topics.inlining"></a><a class="link" href="advanced_topics.html#boost_localfunction.advanced_topics.inlining" title="Inlining">Inlining</a>
+</h3></div></div></div>
+<p>
+ Local functions can be declared <a href="http://en.wikipedia.org/wiki/Inline_function" target="_top">inline</a>
+ to increase the chances that the compiler will be able to reduce the run-time
+ of the local function call by inlining the generated assembly code. A local
+ function is declared inline by prefixing its name with the keyword <code class="computeroutput"><span class="keyword">inline</span></code>:
+ </p>
+<pre class="programlisting"><span class="emphasis"><em>result-type</em></span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="emphasis"><em>parameters</em></span><span class="special">)</span> <span class="special">{</span>
+ <span class="special">...</span> <span class="comment">// Body.</span>
+<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="keyword">inline</span> <span class="emphasis"><em>name</em></span><span class="special">)</span> <span class="comment">// Inlining.</span>
+</pre>
+<p>
+ When inlining a local function, note the following:
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+ On <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/standards" target="_top">C++03</a>
+ compliant compilers, inline local functions always have a run-time comparable
+ to their equivalent implementation that uses local functors (see the
+ <a class="link" href="alternatives.html" title="Annex: Alternatives">Alternatives</a>
+ section). However, inline local functions have the important limitation
+ that they cannot be assigned to other functors (like <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span></code>)
+ and they cannot be passed as template parameters.
+ </li>
+<li class="listitem">
+ On <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a>
+ compilers, <code class="computeroutput"><span class="keyword">inline</span></code> has no
+ effect because this library will automatically generate code that uses
+ <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a> specific
+ features to inline the local function calls whenever possible even if
+ the local function is not declared inline. Furthermore, non <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a>
+ local functions can always be passes as template parameters even when
+ they are declared inline. <sup>[<a name="boost_localfunction.advanced_topics.inlining.f0" href="#ftn.boost_localfunction.advanced_topics.inlining.f0" class="footnote">23</a>]</sup>
+ </li>
+</ul></div>
+<div class="important"><table border="0" summary="Important">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="../../../../../doc/src/images/important.png"></td>
+<th align="left">Important</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ It is recommended to not declare a local function inline unless it is strictly
+ necessary for optimizing pure <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/standards" target="_top">C++03</a>
+ compliant code (because in all other cases this library will automatically
+ take advantage of <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a>
+ features to optimize the local function calls while always allowing to
+ pass the local function as a template parameter).
+ </p></td></tr>
+</table></div>
+<p>
+ For example, the following local function is declared inline (thus a for-loop
+ needs to be used for portability instead of passing the local function as
+ a template parameter to the <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span></code>
+ algorithm, see also <a href="../../../test/add_inline.cpp" target="_top"><code class="literal">add_inline.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><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">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="keyword">inline</span> <span class="identifier">add</span><span class="special">)</span> <span class="comment">// Inlining.</span>
+
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">v</span><span class="special">(</span><span class="number">100</span><span class="special">);</span>
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">fill</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="number">1</span><span class="special">);</span>
+
+<span class="keyword">for</span><span class="special">(</span><span class="identifier">size_t</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">size</span><span class="special">();</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">add</span><span class="special">(</span><span class="identifier">v</span><span class="special">[</span><span class="identifier">i</span><span class="special">]);</span> <span class="comment">// Cannot use for_each.</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="section boost_localfunction_advanced_topics_recursion">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.advanced_topics.recursion"></a><a class="link" href="advanced_topics.html#boost_localfunction.advanced_topics.recursion" title="Recursion">Recursion</a>
+</h3></div></div></div>
+<p>
+ Local functions can be declared <a href="http://en.wikipedia.org/wiki/Recursion_(computer_science)#Recursive_procedures" target="_top">recursive</a>
+ so a local function can recursively call itself from its body (as usual with
+ C++ functions). A local function is declared recursive by prefixing its name
+ with the <code class="computeroutput"><span class="identifier">recursive</span></code> "keyword"
+ (thus <code class="computeroutput"><span class="identifier">recursive</span></code> cannot be
+ used as a local function name):
+ </p>
+<pre class="programlisting"><span class="emphasis"><em>result-type</em></span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="emphasis"><em>parameters</em></span><span class="special">)</span> <span class="special">{</span>
+ <span class="special">...</span> <span class="comment">// Body.</span>
+<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">recursive</span> <span class="emphasis"><em>name</em></span><span class="special">)</span> <span class="comment">// Recursive.</span>
+</pre>
+<p>
+ For example, the following local function is used to recursively calculate
+ the factorials of all the numbers in the specified vector (see also <a href="../../../test/factorial.cpp" target="_top"><code class="literal">factorial.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">calculator</span> <span class="special">{</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">results</span><span class="special">;</span>
+
+ <span class="keyword">void</span> <span class="identifier">factorials</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;&amp;</span> <span class="identifier">nums</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="identifier">bind</span> <span class="identifier">this_</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">num</span><span class="special">,</span>
+ <span class="keyword">bool</span> <span class="identifier">recursion</span><span class="special">,</span> <span class="keyword">default</span> <span class="keyword">false</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">result</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
+
+ <span class="keyword">if</span><span class="special">(</span><span class="identifier">num</span> <span class="special">&lt;=</span> <span class="number">0</span><span class="special">)</span> <span class="identifier">result</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span>
+ <span class="keyword">else</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">num</span> <span class="special">*</span> <span class="identifier">factorial</span><span class="special">(</span><span class="identifier">num</span> <span class="special">-</span> <span class="number">1</span><span class="special">,</span> <span class="keyword">true</span><span class="special">);</span> <span class="comment">// Recursive call.</span>
+
+ <span class="keyword">if</span><span class="special">(!</span><span class="identifier">recursion</span><span class="special">)</span> <span class="identifier">this_</span><span class="special">-&gt;</span><span class="identifier">results</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">result</span><span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">result</span><span class="special">;</span>
+ <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">recursive</span> <span class="identifier">factorial</span><span class="special">)</span> <span class="comment">// Recursive.</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">begin</span><span class="special">(),</span> <span class="identifier">nums</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">factorial</span><span class="special">);</span>
+ <span class="special">}</span>
+<span class="special">};</span>
+</pre>
+<p>
+ </p>
+<p>
+ Compilers have not been observed to be able to inline recursive local function
+ calls not even when the recursive local function is also declared inline:
+ </p>
+<pre class="programlisting"><span class="special">...</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="keyword">inline</span> <span class="identifier">recursive</span> <span class="identifier">factorial</span><span class="special">)</span>
+</pre>
+<p>
+ Recursive local functions should never be called outside their declaration
+ scope. <sup>[<a name="boost_localfunction.advanced_topics.recursion.f0" href="#ftn.boost_localfunction.advanced_topics.recursion.f0" class="footnote">24</a>]</sup>
+ </p>
+<div class="warning"><table border="0" summary="Warning">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../doc/src/images/warning.png"></td>
+<th align="left">Warning</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ If a local function is returned from the enclosing function and called
+ in a different scope, the behaviour is undefined (and it will likely result
+ in a run-time error).
+ </p></td></tr>
+</table></div>
+<p>
+ This is not a limitation with respect to <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a> because lambdas can never call themselves recursively
+ (in other words, there is no recursive lambda function that can successfully
+ be called outside its declaration scope because there is no recursive lambda
+ function at all).
+ </p>
+</div>
+<div class="section boost_localfunction_advanced_topics_overloading">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.advanced_topics.overloading"></a><a class="link" href="advanced_topics.html#boost_localfunction.advanced_topics.overloading" title="Overloading">Overloading</a>
+</h3></div></div></div>
+<p>
+ Because local functions are functors, it is possible to overload them using
+ the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">overloaded_function</span></code> functor of <a href="http://www.boost.org/libs/functional/overloaded_function" target="_top">Boost.Functional/OverloadedFunction</a>
+ from the <code class="literal">boost/functional/overloaded_function.hpp</code> header
+ (see the <a href="http://www.boost.org/libs/functional/overloaded_function" target="_top">Boost.Functional/OverloadedFunction</a>
+ documentation for details).
+ </p>
+<p>
+ In the following example, the overloaded function object <code class="computeroutput"><span class="identifier">add</span></code>
+ can be called with signatures from either the local function <code class="computeroutput"><span class="identifier">add_s</span></code>, or the local function <code class="computeroutput"><span class="identifier">add_d</span></code>, or the local function <code class="computeroutput"><span class="identifier">add_d</span></code> with its extra default parameter,
+ or the function pointer <code class="computeroutput"><span class="identifier">add_i</span></code>
+ (see also <a href="../../../test/overload.cpp" target="_top"><code class="literal">overload.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">add_i</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">y</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">x</span> <span class="special">+</span> <span class="identifier">y</span><span class="special">;</span> <span class="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">s</span> <span class="special">=</span> <span class="string">"abc"</span><span class="special">;</span>
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">string</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">s</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&amp;</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">return</span> <span class="identifier">s</span> <span class="special">+</span> <span class="identifier">x</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_s</span><span class="special">)</span>
+
+<span class="keyword">double</span> <span class="identifier">d</span> <span class="special">=</span> <span class="number">1.23</span><span class="special">;</span>
+<span class="keyword">double</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">d</span><span class="special">,</span> <span class="keyword">double</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">double</span> <span class="identifier">y</span><span class="special">,</span> <span class="keyword">default</span> <span class="number">0</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">return</span> <span class="identifier">d</span> <span class="special">+</span> <span class="identifier">x</span> <span class="special">+</span> <span class="identifier">y</span><span class="special">;</span>
+<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">add_d</span><span class="special">)</span>
+
+<span class="identifier">boost</span><span class="special">::</span><span class="identifier">overloaded_function</span><span class="special">&lt;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&amp;)</span>
+ <span class="special">,</span> <span class="keyword">double</span> <span class="special">(</span><span class="keyword">double</span><span class="special">)</span>
+ <span class="special">,</span> <span class="keyword">double</span> <span class="special">(</span><span class="keyword">double</span><span class="special">,</span> <span class="keyword">double</span><span class="special">)</span> <span class="comment">// Overload giving default param.</span>
+ <span class="special">,</span> <span class="keyword">int</span> <span class="special">(</span><span class="keyword">int</span><span class="special">,</span> <span class="keyword">int</span><span class="special">)</span>
+<span class="special">&gt;</span> <span class="identifier">add</span><span class="special">(</span><span class="identifier">add_s</span><span class="special">,</span> <span class="identifier">add_d</span><span class="special">,</span> <span class="identifier">add_d</span><span class="special">,</span> <span class="identifier">add_i</span><span class="special">);</span> <span class="comment">// Overloaded function object.</span>
+
+<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">add</span><span class="special">(</span><span class="string">"xyz"</span><span class="special">)</span> <span class="special">==</span> <span class="string">"abcxyz"</span><span class="special">);</span> <span class="comment">// Call `add_s`.</span>
+<span class="identifier">BOOST_TEST</span><span class="special">((</span><span class="number">4.44</span> <span class="special">-</span> <span class="identifier">add</span><span class="special">(</span><span class="number">3.21</span><span class="special">))</span> <span class="special">&lt;=</span> <span class="number">0.001</span><span class="special">);</span> <span class="comment">// Call `add_d` (no default).</span>
+<span class="identifier">BOOST_TEST</span><span class="special">((</span><span class="number">44.44</span> <span class="special">-</span> <span class="identifier">add</span><span class="special">(</span><span class="number">3.21</span><span class="special">,</span> <span class="number">40.0</span><span class="special">))</span> <span class="special">&lt;=</span> <span class="number">0.001</span><span class="special">);</span> <span class="comment">// Call `add_d`.</span>
+<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">add</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="number">2</span><span class="special">)</span> <span class="special">==</span> <span class="number">3</span><span class="special">);</span> <span class="comment">// Call `add_i`.</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="section boost_localfunction_advanced_topics_exception_specifications">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.advanced_topics.exception_specifications"></a><a class="link" href="advanced_topics.html#boost_localfunction.advanced_topics.exception_specifications" title="Exception Specifications">Exception
+ Specifications</a>
+</h3></div></div></div>
+<p>
+ It is possible to program exception specifications for local functions by
+ specifying them after the <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code>
+ macro and before the body code block <code class="computeroutput"><span class="special">{</span>
+ <span class="special">...</span> <span class="special">}</span></code>.
+ </p>
+<div class="important"><table border="0" summary="Important">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="../../../../../doc/src/images/important.png"></td>
+<th align="left">Important</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ Note that the exception specifications only apply to the body code specified
+ by programmers and they do not apply to the rest of the code automatically
+ generated by the macro expansions to implement local functions. For example,
+ even if the body code is specified to throw no exception using <code class="computeroutput"><span class="keyword">throw</span> <span class="special">()</span> <span class="special">{</span> <span class="special">...</span> <span class="special">}</span></code>,
+ the execution of the library code automatically generated by the macros
+ could still throw (if there is no memory, etc).
+ </p></td></tr>
+</table></div>
+<p>
+ For example (see also <a href="../../../test/add_except.cpp" target="_top"><code class="literal">add_except.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">double</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">0.0</span><span class="special">;</span>
+<span class="keyword">int</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span>
+
+<span class="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">double</span> <span class="identifier">num</span><span class="special">)</span> <span class="keyword">throw</span><span class="special">()</span> <span class="special">{</span> <span class="comment">// Throw nothing.</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">100</span><span class="special">);</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="section boost_localfunction_advanced_topics_storage_classifiers">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.advanced_topics.storage_classifiers"></a><a class="link" href="advanced_topics.html#boost_localfunction.advanced_topics.storage_classifiers" title="Storage Classifiers">Storage
+ Classifiers</a>
+</h3></div></div></div>
+<p>
+ Local function parameters support the storage classifiers as usual in <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/standards" target="_top">C++03</a>.
+ The <code class="computeroutput"><span class="keyword">auto</span></code> storage classifier
+ is specified as: <sup>[<a name="boost_localfunction.advanced_topics.storage_classifiers.f0" href="#ftn.boost_localfunction.advanced_topics.storage_classifiers.f0" class="footnote">25</a>]</sup>
+ </p>
+<pre class="programlisting"><span class="keyword">auto</span> <span class="emphasis"><em>parameter-type parameter-name</em></span>
+</pre>
+<p>
+ The <code class="computeroutput"><span class="keyword">register</span></code> storage classifier
+ is specified as:
+ </p>
+<pre class="programlisting"><span class="keyword">register</span> <span class="emphasis"><em>parameter-type parameter-name</em></span>
+</pre>
+<p>
+ For example (see also <a href="../../../test/add_classifiers.cpp" target="_top"><code class="literal">add_classifiers.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">auto</span> <span class="keyword">int</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">register</span> <span class="keyword">int</span> <span class="identifier">y</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Classifiers.</span>
+ <span class="keyword">return</span> <span class="identifier">x</span> <span class="special">+</span> <span class="identifier">y</span><span class="special">;</span>
+<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">add</span><span class="special">)</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="section boost_localfunction_advanced_topics_same_line_expansions">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.advanced_topics.same_line_expansions"></a><a class="link" href="advanced_topics.html#boost_localfunction.advanced_topics.same_line_expansions" title="Same Line Expansions">Same
+ Line Expansions</a>
+</h3></div></div></div>
+<p>
+ In general, it is not possible to expand the <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code>,
+ <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_TPL">BOOST_LOCAL_FUNCTION_TPL</a></code>
+ macros multiple times on the same line. <sup>[<a name="boost_localfunction.advanced_topics.same_line_expansions.f0" href="#ftn.boost_localfunction.advanced_topics.same_line_expansions.f0" class="footnote">26</a>]</sup>
+ </p>
+<p>
+ Therefore, this library provides additional macros <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_ID.html" title="Macro BOOST_LOCAL_FUNCTION_ID">BOOST_LOCAL_FUNCTION_ID</a></code>
+ and <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_ID_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_ID_TPL">BOOST_LOCAL_FUNCTION_ID_TPL</a></code>
+ which can be expanded multiple times on the same line as long as programmers
+ specify unique identifiers as the macros' first parameters. The unique identifier
+ can be any token (not just numeric) that can be successfully concatenated
+ by the preprocessor (e.g., <code class="computeroutput"><span class="identifier">local_function_number_1_at_line_123</span></code>).
+ <sup>[<a name="boost_localfunction.advanced_topics.same_line_expansions.f1" href="#ftn.boost_localfunction.advanced_topics.same_line_expansions.f1" class="footnote">27</a>]</sup>
+ </p>
+<p>
+ The <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_ID.html" title="Macro BOOST_LOCAL_FUNCTION_ID">BOOST_LOCAL_FUNCTION_ID</a></code>
+ and <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_ID_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_ID_TPL">BOOST_LOCAL_FUNCTION_ID_TPL</a></code>
+ macros accept local function parameter declaration lists using 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>.
+ For example (see also <a href="../../../test/same_line.cpp" target="_top"><code class="literal">same_line.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="preprocessor">#define</span> <span class="identifier">LOCAL_INC_DEC</span><span class="special">(</span><span class="identifier">offset</span><span class="special">)</span> <span class="special">\</span>
+ <span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION_ID</span><span class="special">(</span><span class="identifier">BOOST_PP_CAT</span><span class="special">(</span><span class="identifier">inc</span><span class="special">,</span> <span class="identifier">__LINE__</span><span class="special">),</span> <span class="comment">/* unique ID */</span> <span class="special">\</span>
+ <span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">offset</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">{</span> <span class="special">\</span>
+ <span class="keyword">return</span> <span class="identifier">x</span> <span class="special">+</span> <span class="identifier">offset</span><span class="special">;</span> <span class="special">\</span>
+ <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">inc</span><span class="special">)</span> <span class="special">\</span>
+ <span class="special">\</span>
+ <span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION_ID</span><span class="special">(</span><span class="identifier">BOOST_PP_CAT</span><span class="special">(</span><span class="identifier">dec</span><span class="special">,</span> <span class="identifier">__LINE__</span><span class="special">),</span> <span class="special">\</span>
+ <span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">offset</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">{</span> <span class="special">\</span>
+ <span class="keyword">return</span> <span class="identifier">x</span> <span class="special">-</span> <span class="identifier">offset</span><span class="special">;</span> <span class="special">\</span>
+ <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">dec</span><span class="special">)</span>
+
+<span class="preprocessor">#define</span> <span class="identifier">LOCAL_INC_DEC_TPL</span><span class="special">(</span><span class="identifier">offset</span><span class="special">)</span> <span class="special">\</span>
+ <span class="identifier">T</span> <span class="identifier">BOOST_LOCAL_FUNCTION_ID_TPL</span><span class="special">(</span><span class="identifier">BOOST_PP_CAT</span><span class="special">(</span><span class="identifier">inc</span><span class="special">,</span> <span class="identifier">__LINE__</span><span class="special">),</span> <span class="special">\</span>
+ <span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">offset</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">{</span> <span class="special">\</span>
+ <span class="keyword">return</span> <span class="identifier">x</span> <span class="special">+</span> <span class="identifier">offset</span><span class="special">;</span> <span class="special">\</span>
+ <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME_TPL</span><span class="special">(</span><span class="identifier">inc</span><span class="special">)</span> <span class="special">\</span>
+ <span class="special">\</span>
+ <span class="identifier">T</span> <span class="identifier">BOOST_LOCAL_FUNCTION_ID_TPL</span><span class="special">(</span><span class="identifier">BOOST_PP_CAT</span><span class="special">(</span><span class="identifier">dec</span><span class="special">,</span> <span class="identifier">__LINE__</span><span class="special">),</span> <span class="special">\</span>
+ <span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">offset</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">{</span> <span class="special">\</span>
+ <span class="keyword">return</span> <span class="identifier">x</span> <span class="special">-</span> <span class="identifier">offset</span><span class="special">;</span> <span class="special">\</span>
+ <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME_TPL</span><span class="special">(</span><span class="identifier">dec</span><span class="special">)</span>
+
+<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">&gt;</span>
+<span class="keyword">void</span> <span class="identifier">f</span><span class="special">(</span><span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">delta</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">LOCAL_INC_DEC_TPL</span><span class="special">(</span><span class="identifier">delta</span><span class="special">)</span> <span class="comment">// Multiple local functions on same line.</span>
+ <span class="comment">/** @todo back to BOOST_TEST(dec(inc(123)) == 123)) and doc that on vacpp compiler composition doesn't work */</span>
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">inc</span><span class="special">(</span><span class="number">123</span><span class="special">)</span> <span class="special">==</span> <span class="number">123</span> <span class="special">+</span> <span class="identifier">delta</span><span class="special">);</span>
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">dec</span><span class="special">(</span><span class="number">123</span><span class="special">)</span> <span class="special">==</span> <span class="number">123</span> <span class="special">-</span> <span class="identifier">delta</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="keyword">int</span> <span class="identifier">delta</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span>
+
+ <span class="identifier">LOCAL_INC_DEC</span><span class="special">(</span><span class="identifier">delta</span><span class="special">)</span> <span class="comment">// Multiple local functions on same line.</span>
+ <span class="comment">/** @todo back to BOOST_TEST(dec(inc(123)) == 123)) and doc that on vacpp compiler composition doesn't work */</span>
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">inc</span><span class="special">(</span><span class="number">123</span><span class="special">)</span> <span class="special">==</span> <span class="number">123</span> <span class="special">+</span> <span class="identifier">delta</span><span class="special">);</span>
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">dec</span><span class="special">(</span><span class="number">123</span><span class="special">)</span> <span class="special">==</span> <span class="number">123</span> <span class="special">-</span> <span class="identifier">delta</span><span class="special">);</span>
+
+ <span class="identifier">f</span><span class="special">(</span><span class="identifier">delta</span><span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span><span class="special">();</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ As shown by the example above, the <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_ID.html" title="Macro BOOST_LOCAL_FUNCTION_ID">BOOST_LOCAL_FUNCTION_ID</a></code>
+ and <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_ID_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_ID_TPL">BOOST_LOCAL_FUNCTION_ID_TPL</a></code>
+ macros are especially useful when it is necessary to invoke them multiple
+ times within a user-defined macro (because the preprocessor expands all nested
+ macros on the same line).
+ </p>
+</div>
+<div class="section boost_localfunction_advanced_topics_limitations__operators__etc_">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.advanced_topics.limitations__operators__etc_"></a><a class="link" href="advanced_topics.html#boost_localfunction.advanced_topics.limitations__operators__etc_" title="Limitations (operators, etc)">Limitations
+ (operators, etc)</a>
+</h3></div></div></div>
+<p>
+ The following table summarizes all C++ function features indicating those
+ features that are not supported by this library for local functions.
+ </p>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ C++ Function Feature
+ </p>
+ </th>
+<th>
+ <p>
+ Local Function Support
+ </p>
+ </th>
+<th>
+ <p>
+ Comment
+ </p>
+ </th>
+</tr></thead>
+<tbody>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="keyword">export</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ No.
+ </p>
+ </td>
+<td>
+ <p>
+ This is not supported because local functions cannot be templates
+ (plus most C++ compilers do not implement <code class="computeroutput"><span class="keyword">export</span></code>
+ at all).
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="keyword">template</span><span class="special">&lt;</span></code><code class="literal"><span class="emphasis"><em>template-parameter-list</em></span></code><code class="computeroutput"><span class="special">&gt;</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ No.
+ </p>
+ </td>
+<td>
+ <p>
+ This is not supported because local functions are implemented using
+ local classes and <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/standards" target="_top">C++03</a>
+ local classes cannot be templates.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="keyword">explicit</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ No.
+ </p>
+ </td>
+<td>
+ <p>
+ This is not supported because local functions are not constructors.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="keyword">inline</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ Yes.
+ </p>
+ </td>
+<td>
+ <p>
+ Local functions can be specified <code class="computeroutput"><span class="keyword">inline</span></code>
+ to improve the chances that <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/standards" target="_top">C++03</a>
+ compilers can optimize the local function call run-time (but <code class="computeroutput"><span class="keyword">inline</span></code> local functions cannot be
+ passed as template parameters on <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/standards" target="_top">C++03</a>
+ compilers, see the <a class="link" href="advanced_topics.html" title="Advanced Topics">Advanced
+ Topics</a> section).
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="keyword">extern</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ No.
+ </p>
+ </td>
+<td>
+ <p>
+ This is not supported because local functions are always defined
+ locally within the enclosing scope and together with their declarations.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="keyword">static</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ No.
+ </p>
+ </td>
+<td>
+ <p>
+ This is not supported because local functions are not member functions.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="keyword">virtual</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ No.
+ </p>
+ </td>
+<td>
+ <p>
+ This is not supported because local functions are not member functions.
+ <sup>[<a name="boost_localfunction.advanced_topics.limitations__operators__etc_.f0" href="#ftn.boost_localfunction.advanced_topics.limitations__operators__etc_.f0" class="footnote">a</a>]</sup>
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="literal"><span class="emphasis"><em>result-type</em></span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ Yes.
+ </p>
+ </td>
+<td>
+ <p>
+ This is supported (see the <a class="link" href="tutorial.html" title="Tutorial">Tutorial</a>
+ section).
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="literal"><span class="emphasis"><em>function-name</em></span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ Yes.
+ </p>
+ </td>
+<td>
+ <p>
+ Local functions are named and they can call themselves recursively
+ but they cannot be operators (see the <a class="link" href="tutorial.html" title="Tutorial">Tutorial</a>
+ and <a class="link" href="advanced_topics.html" title="Advanced Topics">Advanced
+ Topics</a> sections).
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="literal"><span class="emphasis"><em>parameter-list</em></span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ Yes.
+ </p>
+ </td>
+<td>
+ <p>
+ This is supported and it also supports the <code class="computeroutput"><span class="keyword">auto</span></code>
+ and <code class="computeroutput"><span class="keyword">register</span></code> storage
+ classifiers, default parameters, and binding of variables in scope
+ (see the <a class="link" href="tutorial.html" title="Tutorial">Tutorial</a>
+ and <a class="link" href="advanced_topics.html" title="Advanced Topics">Advanced
+ Topics</a> sections).
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ Trailing <code class="computeroutput"><span class="keyword">const</span></code> qualifier
+ </p>
+ </td>
+<td>
+ <p>
+ No.
+ </p>
+ </td>
+<td>
+ <p>
+ This is not supported because local functions are not member functions.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ Trailing <code class="computeroutput"><span class="keyword">volatile</span></code>
+ qualifier
+ </p>
+ </td>
+<td>
+ <p>
+ No.
+ </p>
+ </td>
+<td>
+ <p>
+ This is not supported because local functions are not member functions.
+ </p>
+ </td>
+</tr>
+</tbody>
+<tbody class="footnotes"><tr><td colspan="3"><div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.advanced_topics.limitations__operators__etc_.f0" href="#boost_localfunction.advanced_topics.limitations__operators__etc_.f0" class="para">a</a>] </sup>
+ <span class="bold"><strong>Rationale.</strong></span> It would be possible
+ to make a local function class inherit from another local function
+ class. However, this "inheritance" feature is not implemented
+ because it seemed of <a href="http://lists.boost.org/Archives/boost/2010/09/170895.php" target="_top">no
+ use</a> given that local functions can be bound to one another
+ thus they can simply call each other directly without recurring
+ to dynamic binding or base function calls.
+ </p></div></td></tr></tbody>
+</table></div>
+<h5>
+<a name="boost_localfunction.advanced_topics.limitations__operators__etc_.h0"></a>
+ <span><a name="boost_localfunction.advanced_topics.limitations__operators__etc_.operators"></a></span><a class="link" href="advanced_topics.html#boost_localfunction.advanced_topics.limitations__operators__etc_.operators">Operators</a>
+ </h5>
+<p>
+ Local functions cannot be operators. Naming a local function <code class="computeroutput"><span class="keyword">operator</span><span class="special">...</span></code>
+ will generate a compile-time error. <sup>[<a name="boost_localfunction.advanced_topics.limitations__operators__etc_.f1" href="#ftn.boost_localfunction.advanced_topics.limitations__operators__etc_.f1" class="footnote">28</a>]</sup>
+ </p>
+<p>
+ For example, the following code does not compile (see also <a href="../../../test/operator_error.cpp" target="_top"><code class="literal">operator_error.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">point</span><span class="special">&amp;</span> <span class="identifier">p</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">point</span><span class="special">&amp;</span> <span class="identifier">q</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">return</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">x</span> <span class="special">==</span> <span class="identifier">q</span><span class="special">.</span><span class="identifier">x</span> <span class="special">&amp;&amp;</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">y</span> <span class="special">==</span> <span class="identifier">q</span><span class="special">.</span><span class="identifier">y</span><span class="special">;</span>
+<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="keyword">operator</span><span class="special">==)</span> <span class="comment">// Error: Cannot use `operator...`.</span>
+</pre>
+<p>
+ </p>
+<h5>
+<a name="boost_localfunction.advanced_topics.limitations__operators__etc_.h1"></a>
+ <span><a name="boost_localfunction.advanced_topics.limitations__operators__etc_.goto"></a></span><a class="link" href="advanced_topics.html#boost_localfunction.advanced_topics.limitations__operators__etc_.goto">Goto</a>
+ </h5>
+<p>
+ It is possible to jump with a <code class="computeroutput"><span class="keyword">goto</span></code>
+ within the local function body. For example, the following compiles (see
+ also <a href="../../../test/goto.cpp" target="_top"><code class="literal">goto.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">error</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">y</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">z</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">if</span><span class="special">(</span><span class="identifier">z</span> <span class="special">&gt;</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">goto</span> <span class="identifier">success</span><span class="special">;</span> <span class="comment">// OK: Can jump within local function.</span>
+ <span class="keyword">return</span> <span class="special">-</span><span class="number">1</span><span class="special">;</span>
+ <span class="identifier">success</span><span class="special">:</span>
+ <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+ <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">validate</span><span class="special">)</span>
+
+ <span class="keyword">return</span> <span class="identifier">validate</span><span class="special">(</span><span class="identifier">x</span> <span class="special">+</span> <span class="identifier">y</span><span class="special">);</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ However, it is not possible to jump with a <code class="computeroutput"><span class="keyword">goto</span></code>
+ from within the local function body to to a label defined in the enclosing
+ scope. For example, the following does not compile (see also <a href="../../../test/goto_error.cpp" target="_top"><code class="literal">goto_error.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">error</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">y</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">z</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">if</span><span class="special">(</span><span class="identifier">z</span> <span class="special">&lt;=</span> <span class="number">0</span><span class="special">)</span> <span class="keyword">goto</span> <span class="identifier">failure</span><span class="special">;</span> <span class="comment">// Error: Cannot jump to enclosing scope.</span>
+ <span class="keyword">else</span> <span class="keyword">goto</span> <span class="identifier">success</span><span class="special">;</span> <span class="comment">// OK: Can jump within local function.</span>
+ <span class="identifier">success</span><span class="special">:</span>
+ <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+ <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">validate</span><span class="special">)</span>
+
+ <span class="keyword">return</span> <span class="identifier">validate</span><span class="special">(</span><span class="identifier">x</span> <span class="special">+</span> <span class="identifier">y</span><span class="special">);</span>
+<span class="identifier">failure</span><span class="special">:</span>
+ <span class="keyword">return</span> <span class="special">-</span><span class="number">1</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="footnotes">
+<br><hr width="100" align="left">
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.advanced_topics.default_parameters.f0" href="#boost_localfunction.advanced_topics.default_parameters.f0" class="para">17</a>] </sup>
+ <span class="bold"><strong>Rationale.</strong></span> The assignment symbol <code class="computeroutput"><span class="special">=</span></code> cannot be used to specify default parameter
+ values because default values are not part of the parameter type so they
+ cannot be handled using template meta-programming. Default parameter values
+ need to be separated from the rest of the parameter declaration using the
+ preprocessor. Specifically, this library needs to use preprocessor meta-programming
+ to remove default values when constructing the local function type and
+ also to count the number of default values to provide the correct set of
+ call operators for the local functor. Therefore, the symbol <code class="computeroutput"><span class="special">=</span></code> cannot be used because it cannot be handled
+ by preprocessor meta-programming (non-alphanumeric symbols cannot be detected
+ by preprocessor meta-programming because they cannot be concatenated by
+ the preprocessor).
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.advanced_topics.default_parameters.f1" href="#boost_localfunction.advanced_topics.default_parameters.f1" class="para">18</a>] </sup>
+ The authors do not personally find the use of the <code class="computeroutput"><span class="identifier">WITH_DEFAULT</span></code>
+ macro more readable and they prefer to use the <code class="computeroutput"><span class="keyword">default</span></code>
+ keyword directly. Furthermore, <code class="computeroutput"><span class="identifier">WITH_DEFAULT</span></code>
+ needs to be defined differently for compilers without variadic macros
+ <code class="computeroutput"><span class="preprocessor">#define</span> <span class="identifier">WITH_DEFAULT</span>
+ <span class="special">(</span><span class="keyword">default</span><span class="special">)</span></code> so it can only be defined by programmers
+ based on the syntax they decide to use (see the <a class="link" href="no_variadic_macros.html" title="Annex: No Variadic Macros">No
+ Variadic Macros</a> section).
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.advanced_topics.commas_and_symbols_in_macros.f0" href="#boost_localfunction.advanced_topics.commas_and_symbols_in_macros.f0" class="para">19</a>] </sup>
+ <span class="bold"><strong>Rationale.</strong></span> This limitation is because
+ this library uses preprocessor token concatenation <code class="literal">##</code>
+ to inspect the macro parameters (to distinguish between function parameters,
+ bound variables, etc) and the C++ preprocessor does not allow to concatenate
+ non-alphanumeric tokens.
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.advanced_topics.commas_and_symbols_in_macros.f1" href="#boost_localfunction.advanced_topics.commas_and_symbols_in_macros.f1" class="para">20</a>] </sup>
+ The preprocessor always interprets unwrapped commas as separating macro
+ parameters. Thus in this case the comma will indicate to the preprocessor
+ that the first macro parameter is <code class="computeroutput"><span class="keyword">const</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">tring</span></code>, the second macro parameter is
+ <code class="computeroutput"><span class="identifier">size_t</span><span class="special">&gt;&amp;</span>
+ <span class="identifier">m</span></code>, etc instead of passing <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="identifier">size_t</span><span class="special">&gt;&amp;</span> <span class="identifier">m</span></code>
+ as a single macro parameter.
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.advanced_topics.accessing_types__concepts__etc_.f0" href="#boost_localfunction.advanced_topics.accessing_types__concepts__etc_.f0" class="para">21</a>] </sup>
+ <span class="bold"><strong>Rationale.</strong></span> The type names <code class="computeroutput"><span class="identifier">result_type</span></code> and <code class="computeroutput"><span class="identifier">arg</span></code><code class="literal"><span class="emphasis"><em>N</em></span></code><code class="computeroutput"><span class="identifier">_type</span></code> follow the <a href="http://www.boost.org/libs/type_traits" target="_top">Boost.TypeTraits</a>
+ naming conventions for function traits.
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.advanced_topics.specifying_types__no_boost_typeof_.f0" href="#boost_localfunction.advanced_topics.specifying_types__no_boost_typeof_.f0" class="para">22</a>] </sup>
+ In the examples of this documentation, bound variables, function parameters,
+ and the result type are specified in this order because this is the order
+ used by <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a>. However, the library accepts bound variables,
+ function parameters, and the result type in any order.
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.advanced_topics.inlining.f0" href="#boost_localfunction.advanced_topics.inlining.f0" class="para">23</a>] </sup>
+ <span class="bold"><strong>Rationale.</strong></span> This library uses an indirect
+ function call via a function pointer in order to pass the local function
+ as a template parameter (see the <a class="link" href="implementation.html" title="Annex: Implementation">Implementation</a>
+ section). No compiler has yet been observed to be able to inline function
+ calls when they use such indirect function pointer calls. Therefore,
+ inline local functions do not use such indirect function pointer call
+ (so they are more likely to be optimized) but because of that they
+ cannot be passed as template parameters. The indirect function pointer
+ call is needed on <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/standards" target="_top">C++03</a>
+ but it is not needed on <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a>
+ (see <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm" target="_top">[N2657]</a>
+ and <a href="http://www.boost.org/libs/chrono" target="_top">Boost.Config</a>'s
+ <code class="computeroutput"><span class="identifier">BOOST_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS</span></code>)
+ thus this library automatically generates local function calls that
+ can be inline on <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a>
+ compilers (even when the local function is not declared inline).
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.advanced_topics.recursion.f0" href="#boost_localfunction.advanced_topics.recursion.f0" class="para">24</a>] </sup>
+ <span class="bold"><strong>Rationale.</strong></span> This limitation comes from
+ the fact that the global functor used to pass the local function as a template
+ parameter (and eventually returned outside the declarations scope) does
+ not know the local function name so the local function name used for recursive
+ call cannot be set in the global functor. This limitation together with
+ preventing the possibility for inlining are the reasons why local functions
+ are not recursive unless programmers explicitly declare them <code class="computeroutput"><span class="identifier">recursive</span></code>.
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.advanced_topics.storage_classifiers.f0" href="#boost_localfunction.advanced_topics.storage_classifiers.f0" class="para">25</a>] </sup>
+ The <code class="computeroutput"><span class="keyword">auto</span></code> storage classifier
+ is part of the <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/standards" target="_top">C++03</a>
+ standard and therefore supported by this library. However, the meaning
+ and usage of the <code class="computeroutput"><span class="keyword">auto</span></code> keyword
+ changed in <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a>.
+ Therefore, use the <code class="computeroutput"><span class="keyword">auto</span></code> storage
+ classifier with the usual care in order to avoid writing <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/standards" target="_top">C++03</a>
+ code that might not work on <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a>.
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.advanced_topics.same_line_expansions.f0" href="#boost_localfunction.advanced_topics.same_line_expansions.f0" class="para">26</a>] </sup>
+ <span class="bold"><strong>Rationale.</strong></span> The <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code>
+ and <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_TPL">BOOST_LOCAL_FUNCTION_TPL</a></code>
+ macros internally use <code class="computeroutput"><span class="identifier">__LINE__</span></code>
+ to generate unique identifiers. Therefore, if these macros are expanded
+ more than on time on the same line, the generated identifiers will no longer
+ be unique and the code will not compile. (This restriction does not apply
+ to MSVC and other compilers that provide the non-standard <code class="computeroutput"><span class="identifier">__COUNTER__</span></code> macro.) Note that 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
+ can always be expanded multiple times on the same line because the unique
+ local function name (and not <code class="computeroutput"><span class="identifier">__LINE__</span></code>)
+ is used by this macro to generate unique identifiers (so there is no need
+ for a <code class="computeroutput"><span class="identifier">BOOST_LOCAL_FUNCTION_NAME_ID</span></code>
+ macro).
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.advanced_topics.same_line_expansions.f1" href="#boost_localfunction.advanced_topics.same_line_expansions.f1" class="para">27</a>] </sup>
+ Because there are restrictions on the set of tokens that the preprocessor
+ can concatenate and because not all compilers correctly implement these
+ restrictions, it is in general recommended to specify unique identifiers
+ as a combination of alphanumeric tokens.
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.advanced_topics.limitations__operators__etc_.f1" href="#boost_localfunction.advanced_topics.limitations__operators__etc_.f1" class="para">28</a>] </sup>
+ <span class="bold"><strong>Rationale.</strong></span> This is the because a local
+ function name must be a valid local variable name (the local variable used
+ to hold the local functor) and operators cannot be used as local variable
+ names.
+ </p></div>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2009-2012 Lorenzo
+ Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="tutorial.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="examples.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/libs/local_function/doc/html/boost_localfunction/alternatives.html b/libs/local_function/doc/html/boost_localfunction/alternatives.html
new file mode 100644
index 000000000..3d42ba994
--- /dev/null
+++ b/libs/local_function/doc/html/boost_localfunction/alternatives.html
@@ -0,0 +1,1070 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Annex: Alternatives</title>
+<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="prev" href="examples.html" title="Examples">
+<link rel="next" href="no_variadic_macros.html" title="Annex: No Variadic Macros">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="examples.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="no_variadic_macros.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="section boost_localfunction_alternatives">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_localfunction.alternatives"></a><a class="link" href="alternatives.html" title="Annex: Alternatives">Annex: Alternatives</a>
+</h2></div></div></div>
+<p>
+ This section compares the features offered by this library with similar features
+ offered by C++ and by other libraries.
+ </p>
+<h4>
+<a name="boost_localfunction.alternatives.h0"></a>
+ <span><a name="boost_localfunction.alternatives.features"></a></span><a class="link" href="alternatives.html#boost_localfunction.alternatives.features">Features</a>
+ </h4>
+<p>
+ The following table compares local function features.
+ </p>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+<col>
+<col>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ Local Function Feature
+ </p>
+ </th>
+<th>
+ <p>
+ Boost.LocalFunction
+ </p>
+ </th>
+<th>
+ <p>
+ C++11 Lambda Function (Not C++03)
+ </p>
+ </th>
+<th>
+ <p>
+ Local Functor
+ </p>
+ </th>
+<th>
+ <p>
+ Global Functor (Not Local)
+ </p>
+ </th>
+<th>
+ <p>
+ Boost.Phoenix
+ </p>
+ </th>
+</tr></thead>
+<tbody>
+<tr>
+<td>
+ <p>
+ <span class="emphasis"><em>Can be defined locally</em></span>
+ </p>
+ </td>
+<td>
+ <p>
+ Yes.
+ </p>
+ </td>
+<td>
+ <p>
+ Yes.
+ </p>
+ </td>
+<td>
+ <p>
+ Yes.
+ </p>
+ </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>
+</tr>
+<tr>
+<td>
+ <p>
+ <span class="emphasis"><em>Can be defined using C++ statement syntax</em></span>
+ </p>
+ </td>
+<td>
+ <p>
+ Yes. Plus eventual compiler errors and debugging retain their usual
+ meaning and format.
+ </p>
+ </td>
+<td>
+ <p>
+ Yes. Plus eventual compiler errors and debugging retain their usual
+ meaning and format.
+ </p>
+ </td>
+<td>
+ <p>
+ Yes. Plus eventual compiler errors and debugging retain their usual
+ meaning and format.
+ </p>
+ </td>
+<td>
+ <p>
+ Yes. Plus eventual compiler errors and debugging retain their usual
+ meaning and format.
+ </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>
+ <p>
+ <span class="emphasis"><em>Can be defined within expressions</em></span>
+ </p>
+ </td>
+<td>
+ <p>
+ No. It can be defined only within declarations.
+ </p>
+ </td>
+<td>
+ <p>
+ Yes (plus the local function can be unnamed).
+ </p>
+ </td>
+<td>
+ <p>
+ No. It can be defined only within declarations.
+ </p>
+ </td>
+<td>
+ <p>
+ No. It can be defined only within declarations.
+ </p>
+ </td>
+<td>
+ <p>
+ Yes (plus the local function can be unnamed).
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <span class="emphasis"><em>Can be passed as template parameter (e.g., to STL algorithms)</em></span>
+ </p>
+ </td>
+<td>
+ <p>
+ Yes. The <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/standards" target="_top">C++03</a>
+ standard does not allow to pass local types as template parameters
+ (see <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm" target="_top">[N2657]</a>)
+ but this library implements a "trick" to get around this
+ limitation (see the <a class="link" href="implementation.html" title="Annex: Implementation">Implementation</a>
+ section).
+ </p>
+ </td>
+<td>
+ <p>
+ Yes.
+ </p>
+ </td>
+<td>
+ <p>
+ No on <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/standards" target="_top">C++03</a>
+ compilers (but yes on <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a>
+ compilers and some compilers like MSVC 8.0, see <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm" target="_top">[N2657]</a>).
+ </p>
+ </td>
+<td>
+ <p>
+ Yes.
+ </p>
+ </td>
+<td>
+ <p>
+ Yes.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <span class="emphasis"><em>Access variables in scope</em></span>
+ </p>
+ </td>
+<td>
+ <p>
+ 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 <code class="computeroutput"><span class="keyword">this</span></code>
+ can also be bound using <code class="computeroutput"><span class="identifier">this_</span></code>).
+ </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
+ (the object <code class="computeroutput"><span class="keyword">this</span></code> can
+ also be bound). However, variables cannot be bound by constant references
+ (see below).
+ </p>
+ </td>
+<td>
+ <p>
+ No. Programmers must manually program functor data members and explicitly
+ specify their types to access variables in scope.
+ </p>
+ </td>
+<td>
+ <p>
+ No. Programmers must manually program functor data members and explicitly
+ specify their types to access variables in scope.
+ </p>
+ </td>
+<td>
+ <p>
+ Yes. Variables in scope are accessible as usual within expressions
+ (plus <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">let</span></code> can be used to bind variables
+ by constant reference).
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <span class="emphasis"><em><a href="http://en.wikipedia.org/wiki/Type_polymorphism#Parametric_polymorphism" target="_top">Polymorphic</a>
+ in the function parameter type</em></span>
+ </p>
+ </td>
+<td>
+ <p>
+ No (local functions cannot be function templates).
+ </p>
+ </td>
+<td>
+ <p>
+ No (<a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a>
+ lambdas cannot be function templates).
+ </p>
+ </td>
+<td>
+ <p>
+ No (local classes cannot have member function templates).
+ </p>
+ </td>
+<td>
+ <p>
+ Yes.
+ </p>
+ </td>
+<td>
+ <p>
+ Yes.
+ </p>
+ </td>
+</tr>
+</tbody>
+</table></div>
+<p>
+ <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 functions</a> have most of the features of this library plus some
+ additional feature (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">
+ <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a> can be defined within expressions while this library
+ local functions can only be defined at declaration scope.
+ </li>
+<li class="listitem">
+ <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a> are only supported by the <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a>
+ standard so they are not supported by all C++ compilers. This library local
+ functions can be programmed also on <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/standards" target="_top">C++03</a>
+ 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 functions</a> on <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a>
+ compilers).
+ </li>
+<li class="listitem">
+ <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a> do not allow to bind variables in scope by constant
+ reference. Because a variable cannot be bound by constant reference, <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a> 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. Constant
+ reference binding is instead supported by this library.
+ </li>
+<li class="listitem">
+ <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a> do not allow to bind data members selectively
+ without binding also the object <code class="computeroutput"><span class="keyword">this</span></code>
+ while this library local functions can bind either selected data members
+ or the entire object <code class="computeroutput"><span class="keyword">this</span></code>
+ (using <code class="computeroutput"><span class="identifier">this_</span></code>).
+ </li>
+<li class="listitem">
+ <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a> provide a short-hand syntax to bind all variables
+ in scope at once (<code class="computeroutput"><span class="special">&amp;</span></code> or
+ <code class="computeroutput"><span class="special">=</span></code>) while this library local
+ function always require to bind variables naming them one-by-one.
+ </li>
+</ul></div>
+<p>
+ For example, for non-copyable objects (see also <a href="../../../example/noncopyable_cxx11_lambda_error.cpp" target="_top"><code class="literal">noncopyable_cxx11_lambda_error.cpp</code></a>
+ and <a href="../../../example/noncopyable_local_function.cpp" target="_top"><code class="literal">noncopyable_local_function.cpp</code></a>):
+ </p>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ C++11 Lambda Function
+ </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="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>
+<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="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="identifier">BOOST_TYPEOF_REGISTER_TYPE</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="comment">// Register for `bind&amp; x` below.</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>
+ Or, for objects with expensive copy operations (see also <a href="../../../example/expensive_copy_cxx11_lambda.cpp" target="_top"><code class="literal">expensive_copy_cxx11_lambda.cpp</code></a>
+ and <a href="../../../example/expensive_copy_local_function.cpp" target="_top"><code class="literal">expensive_copy_local_function.cpp</code></a>):
+ </p>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ C++11 Lambda Function
+ </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="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 operation.</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 operation.</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="identifier">BOOST_TYPEOF_REGISTER_TYPE</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="comment">// Register for `bind&amp; x` below.</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 expensive</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">// copy but 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>
+ 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 functions</a>, the best alternative might be to bind an extra local
+ variable declared constant and initialized to the original variable (for example,
+ see <span class="emphasis"><em>constant blocks</em></span> implemented with <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a> in the <a class="link" href="examples.html" title="Examples">Examples</a>
+ section).
+ </p>
+<p>
+ <span class="bold"><strong>Local Functor</strong></span>
+ </p>
+<p>
+ The following example compares local functions with C++ local functors (see
+ also <a href="../../../example/add_local_functor.cpp" target="_top"><code class="literal">add_local_functor.cpp</code></a>
+ and <a href="../../../test/add.cpp" target="_top"><code class="literal">add.cpp</code></a>):
+ </p>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ Local Functor
+ </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="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="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="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_TEST</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="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</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">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="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_TEST</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="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span><span class="special">();</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+ </td>
+</tr></tbody>
+</table></div>
+<p>
+ <span class="bold"><strong>Global Functor</strong></span>
+ </p>
+<p>
+ The following example compares local functions with C++ global functors (see
+ also <a href="../../../example/add_global_functor.cpp" target="_top"><code class="literal">add_global_functor.cpp</code></a>
+ and <a href="../../../test/add.cpp" target="_top"><code class="literal">add.cpp</code></a>):
+ </p>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ Global Functor
+ </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="comment">// Unfortunately, cannot be defined locally (so not a 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="identifier">factor</span><span class="special">;</span> <span class="comment">// Make `factor` constant.</span>
+<span class="special">};</span>
+
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">void</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_TEST</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="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</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">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="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_TEST</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="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span><span class="special">();</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+ </td>
+</tr></tbody>
+</table></div>
+<p>
+ 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>
+ <span class="bold"><strong>Boost.Phoenix</strong></span>
+ </p>
+<p>
+ The following example compares local functions with <a href="http://www.boost.org/libs/phoenix" target="_top">Boost.Phoenix</a>
+ (see also <a href="../../../example/add_phoenix.cpp" target="_top"><code class="literal">add_phoenix.cpp</code></a>
+ and <a href="../../../test/add.cpp" target="_top"><code class="literal">add.cpp</code></a>):
+ </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="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="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">let</span><span class="special">;</span>
+ <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">local_names</span><span class="special">::</span><span class="identifier">_f</span><span class="special">;</span>
+ <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">cref</span><span class="special">;</span>
+ <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">ref</span><span class="special">;</span>
+ <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">arg_names</span><span class="special">::</span><span class="identifier">_1</span><span class="special">;</span>
+
+ <span class="keyword">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="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="special">,</span> <span class="identifier">_1</span> <span class="comment">// Access `sum` by reference.</span>
+ <span class="special">]);</span>
+
+ <span class="identifier">BOOST_TEST</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="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</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">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="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_TEST</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="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span><span class="special">();</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+ </td>
+</tr></tbody>
+</table></div>
+<p>
+ The comparison in this section does not include the <a href="http://www.boost.org/libs/lambda" target="_top">Boost.Lambda</a>
+ library because that library is obsolete and it was replaced by <a href="http://www.boost.org/libs/phoenix" target="_top">Boost.Phoenix</a>.
+ The <a href="http://www.boost.org/libs/phoenix" target="_top">Boost.Phoenix</a> library
+ version 3.0 is used for this comparison.
+ </p>
+<h4>
+<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>
+ </h4>
+<p>
+ The following tables compare run-times, compile-times, and binary sizes for
+ the different alternatives to local functions presented in this section.
+ </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 <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/standards" target="_top">C++03</a>
+ 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
+ <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a> features
+ enabled <code class="literal">-std=c++0x</code>, see also <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm" target="_top">[N2657]</a>
+ and <a href="http://www.boost.org/libs/chrono" target="_top">Boost.Config</a>'s <code class="computeroutput"><span class="identifier">BOOST_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS</span></code>)
+ this library automatically generates optimized code that runs as fast as the
+ fastest of the other approaches (see the "Boost.LocalFunction" approach
+ below). When this library local function is specified <code class="computeroutput"><span class="keyword">inline</span></code>
+ (see the "Boost.LocalFunction Inline" approach 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. However, in these cases the local function
+ cannot be portably passed as template parameter (see <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm" target="_top">[N2657]</a>
+ and <a href="http://www.boost.org/libs/chrono" target="_top">Boost.Config</a>'s <code class="computeroutput"><span class="identifier">BOOST_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS</span></code>)
+ 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 (on MSVC
+ the for-loop, and not the local function in fact the same applies to local
+ functors, was measured to have worst performances than using <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span></code>).
+ 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> <span class="special">...</span></code>).
+ </p>
+<div class="note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ The run-time performances of this library local functions are explained because
+ on <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/standards" target="_top">C++03</a>
+ 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 portably pass the
+ local function class as a template parameter (see <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm" target="_top">[N2657]</a>
+ 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 (e.g., <a href="http://www.boost.org/libs/phoenix" target="_top">Boost.Phoenix</a>)
+ 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 <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a>
+ features enabled <code class="literal">-std=c++0x</code>, see <a href="http://www.boost.org/libs/chrono" target="_top">Boost.Config</a>'s
+ <code class="computeroutput"><span class="identifier">BOOST_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS</span></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>
+ This run-time performance cost on <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/standards" target="_top">C++03</a>
+ 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.
+ </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 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 compiler from inlining function objects also other approaches like <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a> and <a href="http://www.boost.org/libs/phoenix" target="_top">Boost.Phoenix</a>
+ <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; touch &lt;FILE_NAME&gt;.cpp # force recompilation
+&gt; python chrono.py bjam {release|debug} &lt;FILE_NAME&gt; # compile-time
+&gt; size &lt;FILE_NAME&gt; # binary size
+&gt; ./&lt;FILE_NAME&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 <a href="http://www.boost.org/libs/chrono" target="_top">Boost.Chrono</a>
+ 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>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ Legend
+ </p>
+ </th>
+<th>
+ <p>
+ Approach
+ </p>
+ </th>
+<th>
+ <p>
+ Source File
+ </p>
+ </th>
+</tr></thead>
+<tbody>
+<tr>
+<td>
+ <p>
+ <span class="inlinemediaobject"><img src="../../../example/profile_legend_local_function.png" alt="profile_legend_local_function"></span>
+ </p>
+ </td>
+<td>
+ <p>
+ <a href="http://www.boost.org/libs/local_function" target="_top">Boost.LocalFunction</a>
+ </p>
+ </td>
+<td>
+ <p>
+ <a href="../../../example/profile_local_function.cpp" target="_top"><code class="literal">profile_local_function.cpp</code></a>
+ </p>
+ </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>
+ <a href="http://www.boost.org/libs/local_function" target="_top">Boost.LocalFunction</a>
+ inline
+ </p>
+ </td>
+<td>
+ <p>
+ <a href="../../../example/profile_local_function_inline.cpp" target="_top"><code class="literal">profile_local_function_inline.cpp</code></a>
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <span class="inlinemediaobject"><img src="../../../example/profile_legend_cxx11_lambda.png" alt="profile_legend_cxx11_lambda"></span>
+ </p>
+ </td>
+<td>
+ <p>
+ <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a>
+ Lambda Function <sup>[<a name="boost_localfunction.alternatives.f0" href="#ftn.boost_localfunction.alternatives.f0" class="footnote">a</a>]</sup>
+ </p>
+ </td>
+<td>
+ <p>
+ <a href="../../../example/profile_cxx11_lambda.cpp" target="_top"><code class="literal">profile_cxx11_lambda.cpp</code></a>
+ </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>
+ <a href="../../../example/profile_local_functor.cpp" target="_top"><code class="literal">profile_local_functor.cpp</code></a>
+ </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>
+ <a href="../../../example/profile_global_functor.cpp" target="_top"><code class="literal">profile_global_functor.cpp</code></a>
+ </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>
+ <a href="http://www.boost.org/libs/phoenix" target="_top">Boost.Phoenix</a>
+ </p>
+ </td>
+<td>
+ <p>
+ <a href="../../../example/profile_phoenix.cpp" target="_top"><code class="literal">profile_phoenix.cpp</code></a>
+ </p>
+ </td>
+</tr>
+</tbody>
+<tbody class="footnotes"><tr><td colspan="3"><div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.alternatives.f0" href="#boost_localfunction.alternatives.f0" class="para">a</a>] </sup>
+ Measurements available only for <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a>
+ compilers.
+ </p></div></td></tr></tbody>
+</table></div>
+<div class="informaltable"><table class="table">
+<colgroup><col></colgroup>
+<thead><tr><th>
+ <p>
+ GCC 4.5.3 With C++11 Lambda Functions and "Local Classes as
+ Template Parameters" (<code class="literal">bjam cxxflags=-std=c++0x ...</code>)
+ </p>
+ </th></tr></thead>
+<tbody>
+<tr><td>
+ <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_cxx11_release.png" width="1170" alt="profile_gcc_cxx11_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_cxx11_debug.png" width="1170" alt="profile_gcc_cxx11_debug"></span>
+ </p>
+ </td></tr>
+</tbody>
+</table></div>
+<div class="informaltable"><table class="table">
+<colgroup><col></colgroup>
+<thead><tr><th>
+ <p>
+ MSVC 8.0 With "Local Classes as Template Parameters" (Without
+ C++11 Lambda Functions)
+ </p>
+ </th></tr></thead>
+<tbody>
+<tr><td>
+ <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_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_debug.png" width="1170" alt="profile_msvc_debug"></span>
+ </p>
+ </td></tr>
+</tbody>
+</table></div>
+<div class="informaltable"><table class="table">
+<colgroup><col></colgroup>
+<thead><tr><th>
+ <p>
+ GCC 4.3.4 With <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/standards" target="_top">C++03</a>
+ Only (Without <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a>
+ Lambda Functions and Without "Local Classes as Template Parameters")
+ </p>
+ </th></tr></thead>
+<tbody>
+<tr><td>
+ <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_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_debug.png" width="1170" alt="profile_gcc_debug"></span>
+ </p>
+ </td></tr>
+</tbody>
+</table></div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2009-2012 Lorenzo
+ Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="examples.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="no_variadic_macros.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/libs/local_function/doc/html/boost_localfunction/bibliography.html b/libs/local_function/doc/html/boost_localfunction/bibliography.html
new file mode 100644
index 000000000..a29bb7b27
--- /dev/null
+++ b/libs/local_function/doc/html/boost_localfunction/bibliography.html
@@ -0,0 +1,74 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Bibliography</title>
+<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="prev" href="release_notes.html" title="Release Notes">
+<link rel="next" href="acknowledgments.html" title="Acknowledgments">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="release_notes.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="acknowledgments.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="section boost_localfunction_bibliography">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_localfunction.bibliography"></a><a class="link" href="bibliography.html" title="Bibliography">Bibliography</a>
+</h2></div></div></div>
+<p>
+ This section lists all the bibliographic references cited by this documentation.
+ </p>
+<p>
+ <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2004/n1613.pdf" target="_top">[N1613]</a>
+ Thorsten Ottosen. <span class="emphasis"><em>Proposal to add Design by Contract to C++.</em></span>
+ The C++ Standards Committee, document no. N1613=04-0053, 2004.
+ </p>
+<p>
+ <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2511.html" target="_top">[N2511]</a>
+ Alisdair Meredith. <span class="emphasis"><em>Named Lambdas and Local Functions.</em></span>
+ The C++ Standards Committee, document no. N2511=08-0021, 2008.
+ </p>
+<p>
+ <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2529.pdf" target="_top">[N2529]</a>
+ Jaakko Jarvi, John Freeman, Lawrence Crowl. <span class="emphasis"><em>Lambda Expressions and
+ Closures: Wording for Monomorphic Lambdas (Revision 3).</em></span> The C++
+ Standards Committee, document no. N2529=08-0039, 2008.
+ </p>
+<p>
+ <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2550.pdf" target="_top">[N2550]</a>
+ Jaakko Jarvi, John Freeman, Lawrence Crowl. <span class="emphasis"><em>Lambda Expressions and
+ Closures: Wording for Monomorphic Lambdas (Revision 4).</em></span> The C++
+ Standards Committee, document no. N2550=08-0060, 2008.
+ </p>
+<p>
+ <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm" target="_top">[N2657]</a>
+ John Spicer. <span class="emphasis"><em>Local and Unamed Types as Template Arguments.</em></span>
+ The C++ Standard Committee, document no. N2657=08-0167, 2008.
+ </p>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2009-2012 Lorenzo
+ Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="release_notes.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="acknowledgments.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/libs/local_function/doc/html/boost_localfunction/examples.html b/libs/local_function/doc/html/boost_localfunction/examples.html
new file mode 100644
index 000000000..115e8975d
--- /dev/null
+++ b/libs/local_function/doc/html/boost_localfunction/examples.html
@@ -0,0 +1,710 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Examples</title>
+<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="prev" href="advanced_topics.html" title="Advanced Topics">
+<link rel="next" href="alternatives.html" title="Annex: Alternatives">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="advanced_topics.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="alternatives.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="section boost_localfunction_examples">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_localfunction.examples"></a><a class="link" href="examples.html" title="Examples">Examples</a>
+</h2></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"><a href="examples.html#boost_localfunction.examples.gcc_lambdas__without_c__11_">GCC
+ Lambdas (without C++11)</a></span></dt>
+<dt><span class="section"><a href="examples.html#boost_localfunction.examples.constant_blocks">Constant
+ Blocks</a></span></dt>
+<dt><span class="section"><a href="examples.html#boost_localfunction.examples.scope_exits">Scope Exits</a></span></dt>
+<dt><span class="section"><a href="examples.html#boost_localfunction.examples.boost_phoenix_functions">Boost.Phoenix
+ Functions</a></span></dt>
+<dt><span class="section"><a href="examples.html#boost_localfunction.examples.closures">Closures</a></span></dt>
+<dt><span class="section"><a href="examples.html#boost_localfunction.examples.gcc_nested_functions">GCC
+ Nested Functions</a></span></dt>
+<dt><span class="section"><a href="examples.html#boost_localfunction.examples.n_papers">N-Papers</a></span></dt>
+</dl></div>
+<p>
+ This section lists some examples that use this library.
+ </p>
+<div class="section boost_localfunction_examples_gcc_lambdas__without_c__11_">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.examples.gcc_lambdas__without_c__11_"></a><a class="link" href="examples.html#boost_localfunction.examples.gcc_lambdas__without_c__11_" title="GCC Lambdas (without C++11)">GCC
+ Lambdas (without C++11)</a>
+</h3></div></div></div>
+<p>
+ Combing local functions with the non-standard <a href="http://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html" target="_top">statement
+ expression</a> extension of the GCC compiler, it is possible to implement
+ lambda functions for GCC compilers even without <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a>
+ support.
+ </p>
+<div class="warning"><table border="0" summary="Warning">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../doc/src/images/warning.png"></td>
+<th align="left">Warning</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ This code only works on compilers that support GCC statement expression
+ extension or that support <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a>.
+ </p></td></tr>
+</table></div>
+<p>
+ For example (see also <a href="../../../example/gcc_lambda.cpp" target="_top"><code class="literal">gcc_lambda.cpp</code></a>
+ and <a href="../../../example/gcc_cxx11_lambda.cpp" target="_top"><code class="literal">gcc_cxx11_lambda.cpp</code></a>):
+ </p>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ With Local Functions (GCC only)
+ </p>
+ </th>
+<th>
+ <p>
+ C++11 Lambdas
+ </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">int</span> <span class="identifier">val</span> <span class="special">=</span> <span class="number">2</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="keyword">int</span><span class="special">*</span> <span class="identifier">end</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="keyword">int</span><span class="special">*</span> <span class="identifier">iter</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">find_if</span><span class="special">(</span><span class="identifier">nums</span><span class="special">,</span> <span class="identifier">end</span><span class="special">,</span>
+ <span class="identifier">GCC_LAMBDA</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">val</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">num</span><span class="special">,</span> <span class="keyword">return</span> <span class="keyword">bool</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">return</span> <span class="identifier">num</span> <span class="special">==</span> <span class="identifier">val</span><span class="special">;</span>
+ <span class="special">}</span> <span class="identifier">GCC_LAMBDA_END</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">int</span> <span class="identifier">val</span> <span class="special">=</span> <span class="number">2</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="keyword">int</span><span class="special">*</span> <span class="identifier">end</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="keyword">int</span><span class="special">*</span> <span class="identifier">iter</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">find_if</span><span class="special">(</span><span class="identifier">nums</span><span class="special">,</span> <span class="identifier">end</span><span class="special">,</span>
+ <span class="special">[</span><span class="identifier">val</span><span class="special">](</span><span class="keyword">int</span> <span class="identifier">num</span><span class="special">)</span> <span class="special">-&gt;</span> <span class="keyword">bool</span> <span class="special">{</span>
+ <span class="keyword">return</span> <span class="identifier">num</span> <span class="special">==</span> <span class="identifier">val</span><span class="special">;</span>
+ <span class="special">}</span>
+<span class="special">);</span>
+</pre>
+<p>
+ </p>
+ </td>
+</tr></tbody>
+</table></div>
+<p>
+ The GCC lambda function macros are implemented using local functions (see
+ also <a href="../../../example/gcc_lambda.hpp" target="_top"><code class="literal">gcc_lambda.hpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="preprocessor"># define</span> <span class="identifier">GCC_LAMBDA_</span><span class="special">(</span><span class="identifier">binds</span><span class="special">,</span> <span class="identifier">params</span><span class="special">,</span> <span class="identifier">results</span><span class="special">)</span> <span class="special">\</span>
+ <span class="special">({</span> <span class="comment">/* open statement expression (GCC extension only) */</span> <span class="special">\</span>
+ <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span> <span class="special">\</span>
+ <span class="identifier">BOOST_PP_LIST_ENUM</span><span class="special">(</span><span class="identifier">BOOST_PP_LIST_APPEND</span><span class="special">(</span><span class="identifier">binds</span><span class="special">,</span> <span class="special">\</span>
+ <span class="identifier">BOOST_PP_LIST_APPEND</span><span class="special">(</span><span class="identifier">params</span><span class="special">,</span> <span class="special">\</span>
+ <span class="identifier">BOOST_PP_IIF</span><span class="special">(</span><span class="identifier">BOOST_PP_LIST_IS_NIL</span><span class="special">(</span><span class="identifier">results</span><span class="special">),</span> <span class="special">\</span>
+ <span class="special">(</span><span class="keyword">return</span> <span class="keyword">void</span><span class="special">,</span> <span class="identifier">BOOST_PP_NIL</span><span class="special">)</span> <span class="comment">/* default for lambdas */</span> <span class="special">\</span>
+ <span class="special">,</span> <span class="special">\</span>
+ <span class="identifier">results</span> <span class="special">\</span>
+ <span class="special">)\</span>
+ <span class="special">)</span> <span class="special">\</span>
+ <span class="special">))</span> <span class="special">\</span>
+ <span class="special">)</span>
+</pre>
+<p>
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="preprocessor">#define</span> <span class="identifier">GCC_LAMBDA_END_</span><span class="special">(</span><span class="identifier">id</span><span class="special">)</span> <span class="special">\</span>
+ <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">BOOST_PP_CAT</span><span class="special">(</span><span class="identifier">gcc_lambda_</span><span class="special">,</span> <span class="identifier">id</span><span class="special">))</span> <span class="special">\</span>
+ <span class="identifier">BOOST_PP_CAT</span><span class="special">(</span><span class="identifier">gcc_lambda_</span><span class="special">,</span> <span class="identifier">id</span><span class="special">);</span> <span class="special">\</span>
+ <span class="special">})</span> <span class="comment">/* close statement expression (GCC extension only) */</span>
+</pre>
+<p>
+ </p>
+<p>
+ This is possible because GCC statement expressions allow to use declaration
+ statements within expressions and therefore to declare a local function within
+ an expression. The macros automatically detect if the compiler supports
+ <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a> in which case the implementation uses native lambdas
+ instead of local functions in GCC statement expressions. However, <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a> do not support constant binding so it is best to
+ only use <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">bind</span>
+ <span class="identifier">variable</span></code> (same as <code class="computeroutput"><span class="special">=</span><span class="identifier">variable</span></code>
+ for <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a>) and <code class="computeroutput"><span class="identifier">bind</span><span class="special">&amp;</span> <span class="identifier">variable</span></code>
+ (same as <code class="computeroutput"><span class="special">&amp;</span><span class="identifier">variable</span></code>
+ for <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a>') because these have the exact same semantic between
+ the local function and the native lambda implementations. Furthermore, local
+ functions allow to bind data members directly while <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a> require to access data members via binding the object
+ <code class="computeroutput"><span class="keyword">this</span></code>. Unfortunately, the short-hand
+ binds <code class="computeroutput"><span class="special">&amp;</span></code> and <code class="computeroutput"><span class="special">=</span></code> of <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a> (which automatically bind all variables in scope
+ either by reference or value) are not supported by these GCC lambda function
+ macros because they are not supported by local functions. Finally, the result
+ type <code class="computeroutput"><span class="keyword">return</span> </code><code class="literal"><span class="emphasis"><em>result-type</em></span></code>
+ is optional and it is assumed <code class="computeroutput"><span class="keyword">void</span></code>
+ when it is not specified (same as with <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a>).
+ </p>
+</div>
+<div class="section boost_localfunction_examples_constant_blocks">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.examples.constant_blocks"></a><a class="link" href="examples.html#boost_localfunction.examples.constant_blocks" title="Constant Blocks">Constant
+ Blocks</a>
+</h3></div></div></div>
+<p>
+ It is possible to use local functions to check assertions between variables
+ that are made constant within the asserted expressions. This is advantageous
+ because assertions are not supposed to change the state of the program and
+ ideally the compiler will not compile assertions that modify variables.
+ </p>
+<p>
+ For example, consider the following assertion where by mistake we programmed
+ <code class="computeroutput"><span class="keyword">operator</span><span class="special">=</span></code>
+ instead of <code class="computeroutput"><span class="keyword">operator</span><span class="special">==</span></code>:
+ </p>
+<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">x</span> <span class="special">=</span> <span class="number">1</span><span class="special">,</span> <span class="identifier">y</span> <span class="special">=</span> <span class="number">2</span><span class="special">;</span>
+<span class="identifier">assert</span><span class="special">(</span><span class="identifier">x</span> <span class="special">=</span> <span class="identifier">y</span><span class="special">);</span> <span class="comment">// Mistakenly `=` instead of `==`.</span>
+</pre>
+<p>
+ Ideally this code will not compile instead this example not only compiles
+ but the assertion even passes the run-time check and no error is generated
+ at all. The <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2004/n1613.pdf" target="_top">[N1613]</a>
+ paper introduces the concept of a <span class="emphasis"><em>const-block</em></span> which
+ could be used to wrap the assertion above and catch the programming error
+ at compile-time. Similarly, the following code will generate a compile-time
+ error when <code class="computeroutput"><span class="keyword">operator</span><span class="special">=</span></code>
+ is mistakenly used instead of <code class="computeroutput"><span class="keyword">operator</span><span class="special">==</span></code> because both <code class="computeroutput"><span class="identifier">x</span></code>
+ and <code class="computeroutput"><span class="identifier">y</span></code> are made constants
+ (using local functions) within the block of code performing the assertion
+ (see also <a href="../../../example/const_block_error.cpp" target="_top"><code class="literal">const_block_error.cpp</code></a>):
+ </p>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ With Local Functions
+ </p>
+ </th>
+<th>
+ <p>
+ N1613 Const-Blocks
+ </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">int</span> <span class="identifier">x</span> <span class="special">=</span> <span class="number">1</span><span class="special">,</span> <span class="identifier">y</span> <span class="special">=</span> <span class="number">2</span><span class="special">;</span>
+<span class="identifier">CONST_BLOCK</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span> <span class="identifier">y</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Constant block.</span>
+ <span class="identifier">assert</span><span class="special">(</span><span class="identifier">x</span> <span class="special">=</span> <span class="identifier">y</span><span class="special">);</span> <span class="comment">// Compiler error.</span>
+<span class="special">}</span> <span class="identifier">CONST_BLOCK_END</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">int</span> <span class="identifier">x</span> <span class="special">=</span> <span class="number">1</span><span class="special">,</span> <span class="identifier">y</span> <span class="special">=</span> <span class="number">2</span><span class="special">;</span>
+<span class="keyword">const</span> <span class="special">{</span> <span class="comment">// Constant block.</span>
+ <span class="identifier">assert</span><span class="special">(</span><span class="identifier">x</span> <span class="special">=</span> <span class="identifier">y</span><span class="special">);</span> <span class="comment">// Compiler error.</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+ </td>
+</tr></tbody>
+</table></div>
+<p>
+ The constant block macros are implemented using local functions (see also
+ <a href="../../../example/const_block.hpp" target="_top"><code class="literal">const_block.hpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="preprocessor">#define</span> <span class="identifier">CONST_BLOCK_</span><span class="special">(</span><span class="identifier">variables</span><span class="special">)</span> <span class="special">\</span>
+ <span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span> <span class="special">\</span>
+ <span class="identifier">BOOST_PP_IIF</span><span class="special">(</span><span class="identifier">BOOST_PP_LIST_IS_NIL</span><span class="special">(</span><span class="identifier">variables</span><span class="special">,</span> <span class="special">\</span>
+ <span class="keyword">void</span> <span class="identifier">BOOST_PP_TUPLE_EAT</span><span class="special">(</span><span class="number">3</span><span class="special">)</span> <span class="special">\</span>
+ <span class="special">,</span> <span class="special">\</span>
+ <span class="identifier">BOOST_PP_LIST_FOR_EACH_I</span> <span class="special">\</span>
+ <span class="special">)(</span><span class="identifier">CONST_BLOCK_BIND_</span><span class="special">,</span> <span class="special">~,</span> <span class="identifier">variables</span><span class="special">)</span> <span class="special">\</span>
+ <span class="special">)</span>
+</pre>
+<p>
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="preprocessor">#define</span> <span class="identifier">CONST_BLOCK_END_</span><span class="special">(</span><span class="identifier">id</span><span class="special">)</span> <span class="special">\</span>
+ <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">BOOST_PP_CAT</span><span class="special">(</span><span class="identifier">const_block_</span><span class="special">,</span> <span class="identifier">id</span><span class="special">))</span> <span class="special">\</span>
+ <span class="identifier">BOOST_PP_CAT</span><span class="special">(</span><span class="identifier">const_block_</span><span class="special">,</span> <span class="identifier">id</span><span class="special">)();</span> <span class="comment">/* call local function immediately */</span>
+</pre>
+<p>
+ </p>
+<p>
+ The constant block macros are implemented using a local function which binds
+ by constant reference <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">&amp;</span></code>
+ all the specified variables (so the variables are constant within the code
+ block but they do not need to be <code class="computeroutput"><span class="identifier">CopyConstructible</span></code>
+ and no extra copy is performed). The local function executes the <code class="computeroutput"><span class="identifier">assert</span></code> instruction in its body and it is
+ called immediately after it is defined. More in general, constant blocks
+ can be used to evaluate any instruction (not just assertions) within a block
+ were all specified variables are constant.
+ </p>
+<p>
+ Unfortunately, constant blocks cannot be implemented with <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a> because these do not support constant binding. Variables
+ bound by value using <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a> (<code class="computeroutput"><span class="identifier">variable</span></code>,
+ <code class="computeroutput"><span class="special">=</span><span class="identifier">variable</span></code>,
+ and <code class="computeroutput"><span class="special">=</span></code>) are constant but they
+ are required to be <code class="computeroutput"><span class="identifier">CopyConstructible</span></code>
+ and they introduce potentially expensive copy operations. <sup>[<a name="boost_localfunction.examples.constant_blocks.f0" href="#ftn.boost_localfunction.examples.constant_blocks.f0" class="footnote">29</a>]</sup> Of course it is always possible to introduce extra constant variables
+ and bind these variables to the <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a> but the constant block code will then have to manage
+ the declaration and initialization of these extra variables plus it will
+ have to use the extra variable names instead of the original variable names:
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">x</span> <span class="special">=</span> <span class="number">1</span><span class="special">,</span> <span class="identifier">y</span> <span class="special">=</span> <span class="number">2</span><span class="special">;</span>
+<span class="keyword">const</span> <span class="identifier">decltype</span><span class="special">(</span><span class="identifier">x</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> <span class="comment">// Constant so cannot be modified</span>
+<span class="keyword">const</span> <span class="identifier">decltype</span><span class="special">(</span><span class="identifier">y</span><span class="special">)&amp;</span> <span class="identifier">const_y</span> <span class="special">=</span> <span class="identifier">y</span><span class="special">;</span> <span class="comment">// and reference so no copy.</span>
+<span class="special">[&amp;</span><span class="identifier">const_x</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">const_y</span><span class="special">]()</span> <span class="special">{</span> <span class="comment">// Lambda functions (C++11 only).</span>
+ <span class="identifier">assert</span><span class="special">(</span><span class="identifier">const_x</span> <span class="special">=</span> <span class="identifier">const_y</span><span class="special">);</span> <span class="comment">// Unfortunately, `const_` names.</span>
+<span class="special">}();</span>
+</pre>
+<p>
+ </p>
+<p>
+ In many cases the use of an extra constant variable <code class="computeroutput"><span class="identifier">const_x</span></code>
+ can be acceptable but in other cases it might be preferable to maintain the
+ same variable name <code class="computeroutput"><span class="identifier">x</span></code> within
+ the function body.
+ </p>
+</div>
+<div class="section boost_localfunction_examples_scope_exits">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.examples.scope_exits"></a><a class="link" href="examples.html#boost_localfunction.examples.scope_exits" title="Scope Exits">Scope Exits</a>
+</h3></div></div></div>
+<p>
+ Scope exits allow to execute arbitrary code at the exit of the enclosing
+ scope and they are provided by the <a href="http://www.boost.org/libs/scope_exit" target="_top">Boost.ScopeExit</a>
+ library.
+ </p>
+<p>
+ For curiosity, here we show how to re-implement scope exits using local functions.
+ One small advantage of scope exits that use local functions is that they
+ support constant binding. <a href="http://www.boost.org/libs/scope_exit" target="_top">Boost.ScopeExit</a>
+ does not directly support constant binding (however, it is always possible
+ to introduce an extra <code class="computeroutput"><span class="keyword">const</span></code>
+ local variable, assign it to the value to bind, and then bind the <code class="computeroutput"><span class="keyword">const</span></code> variable so to effectively have constant
+ binding with <a href="http://www.boost.org/libs/scope_exit" target="_top">Boost.ScopeExit</a>
+ as well).
+ </p>
+<div class="note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ In general, the authors recommend to use <a href="http://www.boost.org/libs/scope_exit" target="_top">Boost.ScopeExit</a>
+ instead of the code listed by this example whenever possible (because
+ <a href="http://www.boost.org/libs/scope_exit" target="_top">Boost.ScopeExit</a>
+ is a library deliberately designed to support the scope exit construct).
+ </p></td></tr>
+</table></div>
+<p>
+ The following example binds <code class="computeroutput"><span class="identifier">p</span></code>
+ by constant reference so this variable cannot be modified within the scope
+ exit body but it is not copied and it will present the value it has at the
+ exit of the enclosing scope and not at the scope exit declaration (see also
+ <a href="../../../example/scope_exit.cpp" target="_top"><code class="literal">scope_exit.cpp</code></a>):
+ </p>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ With Local Functions
+ </p>
+ </th>
+<th>
+ <p>
+ Boost.ScopeExit
+ </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="identifier">person</span><span class="special">&amp;</span> <span class="identifier">p</span> <span class="special">=</span> <span class="identifier">persons_</span><span class="special">.</span><span class="identifier">back</span><span class="special">();</span>
+<span class="identifier">person</span><span class="special">::</span><span class="identifier">evolution_t</span> <span class="identifier">checkpoint</span> <span class="special">=</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">evolution_</span><span class="special">;</span>
+
+<span class="identifier">SCOPE_EXIT</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">checkpoint</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">bind</span><span class="special">&amp;</span> <span class="identifier">p</span><span class="special">,</span> <span class="identifier">bind</span> <span class="identifier">this_</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">if</span> <span class="special">(</span><span class="identifier">checkpoint</span> <span class="special">==</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">evolution_</span><span class="special">)</span> <span class="identifier">this_</span><span class="special">-&gt;</span><span class="identifier">persons_</span><span class="special">.</span><span class="identifier">pop_back</span><span class="special">();</span>
+<span class="special">}</span> <span class="identifier">SCOPE_EXIT_END</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="identifier">person</span><span class="special">&amp;</span> <span class="identifier">p</span> <span class="special">=</span> <span class="identifier">persons_</span><span class="special">.</span><span class="identifier">back</span><span class="special">();</span>
+<span class="identifier">person</span><span class="special">::</span><span class="identifier">evolution_t</span> <span class="identifier">checkpoint</span> <span class="special">=</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">evolution_</span><span class="special">;</span>
+
+<span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">(</span><span class="identifier">checkpoint</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">p</span><span class="special">,</span> <span class="identifier">this_</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Or extra variable `const_p`.</span>
+ <span class="keyword">if</span> <span class="special">(</span><span class="identifier">checkpoint</span> <span class="special">==</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">evolution_</span><span class="special">)</span> <span class="identifier">this_</span><span class="special">-&gt;</span><span class="identifier">persons_</span><span class="special">.</span><span class="identifier">pop_back</span><span class="special">();</span>
+<span class="special">}</span> <span class="identifier">BOOST_SCOPE_EXIT_END</span>
+</pre>
+<p>
+ </p>
+ </td>
+</tr></tbody>
+</table></div>
+<p>
+ The scope exit macros are implemented by passing a local function when constructing
+ an object of the following class (see also <a href="../../../example/scope_exit.hpp" target="_top"><code class="literal">scope_exit.hpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">scope_exit</span> <span class="special">{</span>
+ <span class="identifier">scope_exit</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span><span class="keyword">void</span> <span class="special">(</span><span class="keyword">void</span><span class="special">)&gt;</span> <span class="identifier">f</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="special">{}</span>
+ <span class="special">~</span><span class="identifier">scope_exit</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">f_</span><span class="special">();</span> <span class="special">}</span>
+<span class="keyword">private</span><span class="special">:</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span><span class="keyword">void</span> <span class="special">(</span><span class="keyword">void</span><span class="special">)&gt;</span> <span class="identifier">f_</span><span class="special">;</span>
+<span class="special">};</span>
+</pre>
+<p>
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="preprocessor"># define</span> <span class="identifier">SCOPE_EXIT</span><span class="special">(...)</span> <span class="special">\</span>
+ <span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="identifier">__VA_ARGS__</span><span class="special">)</span>
+</pre>
+<p>
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="preprocessor">#define</span> <span class="identifier">SCOPE_EXIT_END_</span><span class="special">(</span><span class="identifier">id</span><span class="special">)</span> <span class="special">\</span>
+ <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">BOOST_PP_CAT</span><span class="special">(</span><span class="identifier">scope_exit_func_</span><span class="special">,</span> <span class="identifier">id</span><span class="special">))</span> <span class="special">\</span>
+ <span class="identifier">scope_exit</span> <span class="identifier">BOOST_PP_CAT</span><span class="special">(</span><span class="identifier">scope_exit_</span><span class="special">,</span> <span class="identifier">id</span><span class="special">)(</span> <span class="special">\</span>
+ <span class="identifier">BOOST_PP_CAT</span><span class="special">(</span><span class="identifier">scope_exit_func_</span><span class="special">,</span> <span class="identifier">id</span><span class="special">));</span>
+</pre>
+<p>
+ </p>
+<p>
+ A local variable within the enclosing scope is used to hold the object so
+ the destructor will be invoked at the exit of the enclosing scope and it
+ will in turn call the local function executing the scope exit instructions.
+ The scope exit local function has no parameter and <code class="computeroutput"><span class="keyword">void</span></code>
+ result type but it supports binding and constant binding.
+ </p>
+</div>
+<div class="section boost_localfunction_examples_boost_phoenix_functions">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.examples.boost_phoenix_functions"></a><a class="link" href="examples.html#boost_localfunction.examples.boost_phoenix_functions" title="Boost.Phoenix Functions">Boost.Phoenix
+ Functions</a>
+</h3></div></div></div>
+<p>
+ Local functions can be used to create <a href="http://www.boost.org/libs/phoenix" target="_top">Boost.Phoenix</a>
+ functions. For example (see also <a href="../../../example/phoenix_factorial_local.cpp" target="_top"><code class="literal">phoenix_factorial_local.cpp</code></a>
+ and <a href="../../../example/phoenix_factorial.cpp" target="_top"><code class="literal">phoenix_factorial.cpp</code></a>):
+ </p>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ Local Functions
+ </p>
+ </th>
+<th>
+ <p>
+ Global Functor
+ </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">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="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">arg_names</span><span class="special">::</span><span class="identifier">arg1</span><span class="special">;</span>
+
+ <span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Unfortunately, monomorphic.</span>
+ <span class="keyword">return</span> <span class="special">(</span><span class="identifier">n</span> <span class="special">&lt;=</span> <span class="number">0</span><span class="special">)</span> <span class="special">?</span> <span class="number">1</span> <span class="special">:</span> <span class="identifier">n</span> <span class="special">*</span> <span class="identifier">factorial_impl</span><span class="special">(</span><span class="identifier">n</span> <span class="special">-</span> <span class="number">1</span><span class="special">);</span>
+ <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">recursive</span> <span class="identifier">factorial_impl</span><span class="special">)</span>
+
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span><span class="keyword">int</span> <span class="special">(</span><span class="keyword">int</span><span class="special">)&gt;</span> <span class="special">&gt;</span>
+ <span class="identifier">factorial</span><span class="special">(</span><span class="identifier">factorial_impl</span><span class="special">);</span> <span class="comment">// Phoenix function from local function.</span>
+
+ <span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">4</span><span class="special">;</span>
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">factorial</span><span class="special">(</span><span class="identifier">i</span><span class="special">)()</span> <span class="special">==</span> <span class="number">24</span><span class="special">);</span> <span class="comment">// Call.</span>
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">factorial</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">)(</span><span class="identifier">i</span><span class="special">)</span> <span class="special">==</span> <span class="number">24</span><span class="special">);</span> <span class="comment">// Lazy call.</span>
+ <span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</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">factorial_impl</span> <span class="special">{</span> <span class="comment">// Phoenix function from global functor.</span>
+ <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Sig</span><span class="special">&gt;</span>
+ <span class="keyword">struct</span> <span class="identifier">result</span><span class="special">;</span>
+
+ <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">This</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Arg</span><span class="special">&gt;</span>
+ <span class="keyword">struct</span> <span class="identifier">result</span><span class="special">&lt;</span><span class="identifier">This</span> <span class="special">(</span><span class="identifier">Arg</span><span class="special">)&gt;</span> <span class="special">:</span> <span class="identifier">result</span><span class="special">&lt;</span><span class="identifier">This</span> <span class="special">(</span><span class="identifier">Arg</span> <span class="keyword">const</span><span class="special">&amp;)&gt;</span> <span class="special">{};</span>
+
+ <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">This</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Arg</span><span class="special">&gt;</span>
+ <span class="keyword">struct</span> <span class="identifier">result</span><span class="special">&lt;</span><span class="identifier">This</span> <span class="special">(</span><span class="identifier">Arg</span><span class="special">&amp;)&gt;</span> <span class="special">{</span> <span class="keyword">typedef</span> <span class="identifier">Arg</span> <span class="identifier">type</span><span class="special">;</span> <span class="special">};</span>
+
+ <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Arg</span><span class="special">&gt;</span> <span class="comment">// Polymorphic.</span>
+ <span class="identifier">Arg</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">Arg</span> <span class="identifier">n</span><span class="special">)</span> <span class="keyword">const</span> <span class="special">{</span>
+ <span class="keyword">return</span> <span class="special">(</span><span class="identifier">n</span> <span class="special">&lt;=</span> <span class="number">0</span><span class="special">)</span> <span class="special">?</span> <span class="number">1</span> <span class="special">:</span> <span class="identifier">n</span> <span class="special">*</span> <span class="special">(*</span><span class="keyword">this</span><span class="special">)(</span><span class="identifier">n</span> <span class="special">-</span> <span class="number">1</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="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">arg_names</span><span class="special">::</span><span class="identifier">arg1</span><span class="special">;</span>
+
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span><span class="identifier">factorial_impl</span><span class="special">&gt;</span> <span class="identifier">factorial</span><span class="special">;</span>
+
+ <span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">4</span><span class="special">;</span>
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">factorial</span><span class="special">(</span><span class="identifier">i</span><span class="special">)()</span> <span class="special">==</span> <span class="number">24</span><span class="special">);</span> <span class="comment">// Call.</span>
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">factorial</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">)(</span><span class="identifier">i</span><span class="special">)</span> <span class="special">==</span> <span class="number">24</span><span class="special">);</span> <span class="comment">// Lazy call.</span>
+ <span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span><span class="special">();</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+ </td>
+</tr></tbody>
+</table></div>
+<p>
+ This is presented here mainly as a curiosity because <a href="http://www.boost.org/libs/phoenix" target="_top">Boost.Phoenix</a>
+ functions created from local functions have the important limitation that
+ they cannot be polymorphic. <sup>[<a name="boost_localfunction.examples.boost_phoenix_functions.f0" href="#ftn.boost_localfunction.examples.boost_phoenix_functions.f0" class="footnote">30</a>]</sup> Therefore, in many cases creating the <a href="http://www.boost.org/libs/phoenix" target="_top">Boost.Phoenix</a>
+ function from global functors (possibly with the help of <a href="http://www.boost.org/libs/phoenix" target="_top">Boost.Phoenix</a>
+ adaptor macros) might be a more useful.
+ </p>
+</div>
+<div class="section boost_localfunction_examples_closures">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.examples.closures"></a><a class="link" href="examples.html#boost_localfunction.examples.closures" title="Closures">Closures</a>
+</h3></div></div></div>
+<p>
+ The following are examples of <a href="http://en.wikipedia.org/wiki/Closure_(computer_science)" target="_top">closures</a>
+ that illustrate how to return local functions to the calling scope (note
+ how extra care is taken in order to ensure that all bound variables remain
+ valid at the calling scope):
+ </p>
+<div class="informaltable"><table class="table">
+<colgroup><col></colgroup>
+<thead><tr><th>
+ <p>
+ Files
+ </p>
+ </th></tr></thead>
+<tbody>
+<tr><td>
+ <p>
+ <a href="../../../test/return_inc.cpp" target="_top"><code class="literal">return_inc.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/return_this.cpp" target="_top"><code class="literal">return_this.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/return_setget.cpp" target="_top"><code class="literal">return_setget.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/return_derivative.cpp" target="_top"><code class="literal">return_derivative.cpp</code></a>
+ </p>
+ </td></tr>
+</tbody>
+</table></div>
+</div>
+<div class="section boost_localfunction_examples_gcc_nested_functions">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.examples.gcc_nested_functions"></a><a class="link" href="examples.html#boost_localfunction.examples.gcc_nested_functions" title="GCC Nested Functions">GCC
+ Nested Functions</a>
+</h3></div></div></div>
+<p>
+ The GCC C compiler supports local functions as a non-standard extension under
+ the name of <a href="http://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html" target="_top">nested
+ functions</a>. Note that nested functions are exclusively a C extension
+ of the GCC compiler (they are not supported for C++ not even by the GCC compiler,
+ and they are not part of any C or C++ standard, nor they are supported by
+ other compilers like MSVC).
+ </p>
+<p>
+ The following examples are taken form the GCC nested function documentation
+ and programmed using local functions:
+ </p>
+<div class="informaltable"><table class="table">
+<colgroup><col></colgroup>
+<thead><tr><th>
+ <p>
+ Files
+ </p>
+ </th></tr></thead>
+<tbody>
+<tr><td>
+ <p>
+ <a href="../../../example/gcc_square.cpp" target="_top"><code class="literal">gcc_square.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../example/gcc_access.cpp" target="_top"><code class="literal">gcc_access.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../example/gcc_store.cpp" target="_top"><code class="literal">gcc_store.cpp</code></a>
+ </p>
+ </td></tr>
+</tbody>
+</table></div>
+</div>
+<div class="section boost_localfunction_examples_n_papers">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.examples.n_papers"></a><a class="link" href="examples.html#boost_localfunction.examples.n_papers" title="N-Papers">N-Papers</a>
+</h3></div></div></div>
+<p>
+ The following examples are taken from different C++ "N-papers"
+ and programmed using local functions:
+ </p>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ Files
+ </p>
+ </th>
+<th>
+ <p>
+ Notes
+ </p>
+ </th>
+</tr></thead>
+<tbody>
+<tr>
+<td>
+ <p>
+ <a href="../../../example/n2550_find_if.cpp" target="_top"><code class="literal">n2550_find_if.cpp</code></a>
+ </p>
+ </td>
+<td>
+ <p>
+ This example is adapted from <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2550.pdf" target="_top">[N2550]</a>
+ (<a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a>): It passes a local function to the STL
+ algorithm <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">find_if</span></code>.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <a href="../../../example/n2529_this.cpp" target="_top"><code class="literal">n2529_this.cpp</code></a>
+ </p>
+ </td>
+<td>
+ <p>
+ This example is adapted from <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2529.pdf" target="_top">[N2529]</a>
+ (<a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a>): It binds the object in scope <code class="computeroutput"><span class="keyword">this</span></code> to a local function.
+ </p>
+ </td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<div class="footnotes">
+<br><hr width="100" align="left">
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.examples.constant_blocks.f0" href="#boost_localfunction.examples.constant_blocks.f0" class="para">29</a>] </sup>
+ Ideally, <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a> would allow to bind variables also using <code class="computeroutput"><span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">variable</span></code> (constant reference) and <code class="computeroutput"><span class="keyword">const</span><span class="special">&amp;</span></code>
+ (all variables by constant reference).
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.examples.boost_phoenix_functions.f0" href="#boost_localfunction.examples.boost_phoenix_functions.f0" class="para">30</a>] </sup>
+ <span class="bold"><strong>Rationale.</strong></span> Local functions can only be
+ monomorphic because they are implemented using local classes and local
+ classes cannot be templates in C++ (not even in <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a>).
+ </p></div>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2009-2012 Lorenzo
+ Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="advanced_topics.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="alternatives.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/libs/local_function/doc/html/boost_localfunction/getting_started.html b/libs/local_function/doc/html/boost_localfunction/getting_started.html
new file mode 100644
index 000000000..6d3c7b40c
--- /dev/null
+++ b/libs/local_function/doc/html/boost_localfunction/getting_started.html
@@ -0,0 +1,192 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Getting Started</title>
+<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="prev" href="../index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="next" href="tutorial.html" title="Tutorial">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="../index.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="tutorial.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="section boost_localfunction_getting_started">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_localfunction.getting_started"></a><a class="link" href="getting_started.html" title="Getting Started">Getting Started</a>
+</h2></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"><a href="getting_started.html#boost_localfunction.getting_started.this_documentation">This
+ Documentation</a></span></dt>
+<dt><span class="section"><a href="getting_started.html#boost_localfunction.getting_started.compilers_and_platforms">Compilers
+ and Platforms</a></span></dt>
+<dt><span class="section"><a href="getting_started.html#boost_localfunction.getting_started.installation">Installation</a></span></dt>
+</dl></div>
+<p>
+ This section explains how to setup a system to use this library.
+ </p>
+<div class="section boost_localfunction_getting_started_this_documentation">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.getting_started.this_documentation"></a><a class="link" href="getting_started.html#boost_localfunction.getting_started.this_documentation" title="This Documentation">This
+ Documentation</a>
+</h3></div></div></div>
+<p>
+ Programmers should have enough knowledge to use this library after reading
+ the <a class="link" href="../index.html#boost_localfunction.introduction" title="Introduction">Introduction</a>,
+ <a class="link" href="getting_started.html" title="Getting Started">Getting Started</a>,
+ and <a class="link" href="tutorial.html" title="Tutorial">Tutorial</a> sections.
+ The <a class="link" href="advanced_topics.html" title="Advanced Topics">Advanced Topics</a>
+ and <a href="../reference.html" target="_top">Reference</a> sections can be consulted
+ at a later point to gain a more advanced knowledge of the library. All the
+ other sections of this documentation can be considered optional.
+ </p>
+<p>
+ Some footnotes are marked by the word "<span class="bold"><strong>Rationale</strong></span>".
+ They explain reasons behind decisions made during the design and implementation
+ of this library.
+ </p>
+<p>
+ In most of the examples presented in this documentation, the Boost.Detail/LightweightTest
+ (<code class="literal">boost/detail/lightweight_test.hpp</code>) macro <code class="computeroutput"><span class="identifier">BOOST_TEST</span></code> is used to check correctness
+ conditions. The <code class="computeroutput"><span class="identifier">BOOST_TEST</span></code>
+ macro is conceptually similar to <code class="computeroutput"><span class="identifier">assert</span></code>
+ but a failure of the checked condition does not abort the program, instead
+ it makes <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span></code> return a non-zero program
+ exit code. <sup>[<a name="boost_localfunction.getting_started.this_documentation.f0" href="#ftn.boost_localfunction.getting_started.this_documentation.f0" class="footnote">3</a>]</sup>
+ </p>
+</div>
+<div class="section boost_localfunction_getting_started_compilers_and_platforms">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.getting_started.compilers_and_platforms"></a><a class="link" href="getting_started.html#boost_localfunction.getting_started.compilers_and_platforms" title="Compilers and Platforms">Compilers
+ and Platforms</a>
+</h3></div></div></div>
+<p>
+ The implementation of this library uses preprocessor and template meta-programming
+ (as supported by <a href="http://www.boost.org/libs/preprocessor" target="_top">Boost.Preprocessor</a>
+ and <a href="http://www.boost.org/libs/mpl" target="_top">Boost.MPL</a>), templates
+ with partial specializations and function pointers (similarly to <a href="http://www.boost.org/libs/function" target="_top">Boost.Function</a>),
+ and automatic type deduction (as supported by <a href="http://www.boost.org/libs/typeof" target="_top">Boost.Typeof</a>).
+ The authors originally developed and tested the library on:
+ </p>
+<div class="orderedlist"><ol class="orderedlist" type="1">
+<li class="listitem">
+ GNU Compiler Collection (GCC) C++ 4.5.1 on Ubuntu Linux 10.
+ </li>
+<li class="listitem">
+ GCC 4.3.4 and 4.5.3 (with and without <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a>
+ features enabled <code class="computeroutput"><span class="special">-</span><span class="identifier">std</span><span class="special">=</span><span class="identifier">c</span><span class="special">++</span><span class="number">0</span><span class="identifier">x</span></code>)
+ on Cygwin.
+ </li>
+<li class="listitem">
+ Miscrosoft Visual C++ (MSVC) 8.0 on Windows XP and Windows 7.
+ </li>
+</ol></div>
+<p>
+ See the library <a href="http://www.boost.org/development/tests/release/developer/local_function.html" target="_top">regressions
+ test results</a> for detailed information on supported compilers and
+ platforms.
+ </p>
+</div>
+<div class="section boost_localfunction_getting_started_installation">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.getting_started.installation"></a><a class="link" href="getting_started.html#boost_localfunction.getting_started.installation" title="Installation">Installation</a>
+</h3></div></div></div>
+<p>
+ This library is composed of header files only. Therefore there is no pre-compiled
+ object file which needs to be installed or linked. Programmers can simply
+ instruct the C++ compiler where to find the library header files (<code class="computeroutput"><span class="special">-</span><span class="identifier">I</span></code> option
+ for GCC, <code class="computeroutput"><span class="special">/</span><span class="identifier">I</span></code>
+ option for MSVC, etc) and they can start compiling code using this library.
+ </p>
+<p>
+ The library implementation uses <a href="http://www.boost.org/libs/typeof" target="_top">Boost.Typeof</a>
+ to automatically deduce the types of bound variables (see the <a class="link" href="tutorial.html" title="Tutorial">Tutorial</a>
+ section). In order to compile code in type-of emulation mode, all types should
+ be properly registered using <code class="computeroutput"><span class="identifier">BOOST_TYPEOF_REGISTER_TYPE</span></code>
+ and <code class="computeroutput"><span class="identifier">BOOST_TYPEOF_REGISTER_TEMPLATE</span></code>,
+ or appropriate <a href="http://www.boost.org/libs/typeof" target="_top">Boost.Typeof</a>
+ headers should be included (see the source code of most examples presented
+ in this documentation).
+ </p>
+<p>
+ The followings are part of the library private API, they are not documented,
+ and they should not be directly used by programmers: <sup>[<a name="boost_localfunction.getting_started.installation.f0" href="#ftn.boost_localfunction.getting_started.installation.f0" class="footnote">4</a>]</sup>
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+ Any symbol defined by files within the <code class="literal">boost/local_function/aux_/</code>
+ or <code class="literal">boost/local_function/detail/</code> directory (these header
+ files should not be directly included by programmers).
+ </li>
+<li class="listitem">
+ Any symbol within the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">local_function</span><span class="special">::</span><span class="identifier">aux</span></code>
+ or <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">local_function</span><span class="special">::</span><span class="identifier">detail</span></code> namespace.
+ </li>
+<li class="listitem">
+ Any symbol prefixed by <code class="computeroutput"><span class="identifier">boost_local_function_aux_</span><span class="special">...</span></code> or <code class="computeroutput"><span class="identifier">boost_local_function_detail_</span><span class="special">...</span></code> (regardless of its namespace).
+ </li>
+<li class="listitem">
+ Any symbol prefixed by <code class="computeroutput"><span class="identifier">BOOST_LOCAL_FUNCTION_AUX_</span><span class="special">...</span></code> or <code class="computeroutput"><span class="identifier">BOOST_LOCAL_FUNCTION_DETAIL_</span><span class="special">...</span></code> (regardless of its namespace).
+ </li>
+</ul></div>
+<p>
+ Some of the library behaviour can be changed at compile-time by defining
+ special <span class="emphasis"><em>configuration macros</em></span>. If a configuration macro
+ is left undefined, the library will use an appropriate default value for
+ it. All configuration macros are defined in the header file <code class="computeroutput"><a class="link" href="../reference.html#header.boost.local_function.config_hpp" title="Header &lt;boost/local_function/config.hpp&gt;">boost/local_function/config.hpp</a></code>.
+ It is strongly recommended not to change the library configuration macro
+ definitions unless strictly necessary.
+ </p>
+</div>
+<div class="footnotes">
+<br><hr width="100" align="left">
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.getting_started.this_documentation.f0" href="#boost_localfunction.getting_started.this_documentation.f0" class="para">3</a>] </sup>
+ <span class="bold"><strong>Rationale.</strong></span> Using Boost.Detail/LightweightTest
+ allows to add the examples to the library regression tests so to make sure
+ that they always compile and run correctly.
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.getting_started.installation.f0" href="#boost_localfunction.getting_started.installation.f0" class="para">4</a>] </sup>
+ <span class="bold"><strong>Rationale.</strong></span> This library concatenates symbols
+ specified by the programmers (e.g., the local function name) with other
+ symbols (e.g., special prefixes or file line numbers) to make internal
+ symbols with unique names to avoid name clashes. These symbols are separated
+ by the letter "<code class="computeroutput"><span class="identifier">X</span></code>"
+ when they are concatenated so they read more easily during debugging (the
+ underscore character "<code class="computeroutput"><span class="identifier">_</span></code>"
+ could not be used instead of the letter "<code class="computeroutput"><span class="identifier">X</span></code>"
+ because if the original symbols already contained a leading or trailing
+ underscore, the concatenation could result in a symbol with double underscores
+ "<code class="computeroutput"><span class="identifier">__</span></code>" which is
+ reserved by the C++ standard). The "aux" symbols are private
+ to this library while the "detail" symbols may be used within
+ Boost by other libraries but they are still not part of this library public
+ API.
+ </p></div>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2009-2012 Lorenzo
+ Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="../index.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="tutorial.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/libs/local_function/doc/html/boost_localfunction/implementation.html b/libs/local_function/doc/html/boost_localfunction/implementation.html
new file mode 100644
index 000000000..b2a4bbd40
--- /dev/null
+++ b/libs/local_function/doc/html/boost_localfunction/implementation.html
@@ -0,0 +1,230 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Annex: Implementation</title>
+<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="prev" href="no_variadic_macros.html" title="Annex: No Variadic Macros">
+<link rel="next" href="../reference.html" title="Reference">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="no_variadic_macros.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../reference.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="section boost_localfunction_implementation">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_localfunction.implementation"></a><a class="link" href="implementation.html" title="Annex: Implementation">Annex: Implementation</a>
+</h2></div></div></div>
+<p>
+ This section gives an overview of the key programming techniques used to implement
+ this library.
+ </p>
+<div class="note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ The code listed here can be used by curious readers and library maintainers
+ as a reference in trying to understand the library source code. There is
+ absolutely no guarantee that the library implementation uses the exact code
+ listed here.
+ </p></td></tr>
+</table></div>
+<h4>
+<a name="boost_localfunction.implementation.h0"></a>
+ <span><a name="boost_localfunction.implementation.local_classes_as_template_parameters"></a></span><a class="link" href="implementation.html#boost_localfunction.implementation.local_classes_as_template_parameters">Local
+ Classes as Template Parameters</a>
+ </h4>
+<p>
+ This library uses a local class to implement the local function object. However,
+ in <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/standards" target="_top">C++03</a>
+ local classes (and therefore the local function objects they implement) cannot
+ be passed as template parameters (e.g., to the <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span></code>
+ algorithm), this is instead possible in <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a>,
+ MSVC, and some other compilers (see <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm" target="_top">[N2657]</a>
+ and <a href="http://www.boost.org/libs/chrono" target="_top">Boost.Config</a>'s <code class="computeroutput"><span class="identifier">BOOST_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS</span></code>).
+ To work around this limitation, this library investigated the following two
+ "tricks" (both tricks can be extended to support function default
+ parameters):
+ </p>
+<div class="orderedlist"><ol class="orderedlist" type="1">
+<li class="listitem">
+ The <span class="emphasis"><em>casting functor trick</em></span> uses a non-local functor
+ that calls a static member function of the local class via a function pointer.
+ The static member function then calls the correct local function body after
+ type casting the object from a <code class="computeroutput"><span class="keyword">void</span><span class="special">*</span></code> pointer (local classes can always be used
+ for type casting via <code class="computeroutput"><span class="keyword">static_cast</span></code>
+ or similar).
+ </li>
+<li class="listitem">
+ The <span class="emphasis"><em>virtual functor trick</em></span> derives the local functor
+ class from a non-local base class. The correct overridden implementation
+ of the virtual <code class="computeroutput"><span class="keyword">operator</span><span class="special">()</span></code>
+ is then called via dynamic binding.
+ </li>
+</ol></div>
+<p>
+ For example (see also <a href="../../../example/impl_tparam_tricks.cpp" target="_top"><code class="literal">impl_tparam_tricks.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">detail</span><span class="special">/</span><span class="identifier">lightweight_test</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">vector</span><span class="special">&gt;</span>
+<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">algorithm</span><span class="special">&gt;</span>
+
+<span class="comment">// Casting functor trick.</span>
+<span class="keyword">struct</span> <span class="identifier">casting_func</span> <span class="special">{</span>
+ <span class="keyword">explicit</span> <span class="identifier">casting_func</span><span class="special">(</span><span class="keyword">void</span><span class="special">*</span> <span class="identifier">obj</span><span class="special">,</span> <span class="keyword">void</span> <span class="special">(*</span><span class="identifier">call</span><span class="special">)(</span><span class="keyword">void</span><span class="special">*,</span> <span class="keyword">const</span> <span class="keyword">int</span><span class="special">&amp;))</span>
+ <span class="special">:</span> <span class="identifier">obj_</span><span class="special">(</span><span class="identifier">obj</span><span class="special">),</span> <span class="identifier">call_</span><span class="special">(</span><span class="identifier">call</span><span class="special">)</span> <span class="special">{}</span>
+ <span class="comment">// Unfortunately, function pointer call is not inlined.</span>
+ <span class="keyword">inline</span> <span class="keyword">void</span> <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">const</span> <span class="keyword">int</span><span class="special">&amp;</span> <span class="identifier">num</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">call_</span><span class="special">(</span><span class="identifier">obj_</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="keyword">void</span><span class="special">*</span> <span class="identifier">obj_</span><span class="special">;</span>
+ <span class="keyword">void</span> <span class="special">(*</span><span class="identifier">call_</span><span class="special">)(</span><span class="keyword">void</span><span class="special">*,</span> <span class="keyword">const</span> <span class="keyword">int</span><span class="special">&amp;);</span>
+<span class="special">};</span>
+
+<span class="comment">// Virtual functor trick.</span>
+<span class="keyword">struct</span> <span class="identifier">virtual_func</span> <span class="special">{</span>
+ <span class="keyword">struct</span> <span class="identifier">interface</span> <span class="special">{</span>
+ <span class="comment">// Unfortunately, virtual function call is not inlined.</span>
+ <span class="keyword">inline</span> <span class="keyword">virtual</span> <span class="keyword">void</span> <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">const</span> <span class="keyword">int</span><span class="special">&amp;)</span> <span class="special">{}</span>
+ <span class="special">};</span>
+ <span class="keyword">explicit</span> <span class="identifier">virtual_func</span><span class="special">(</span><span class="identifier">interface</span><span class="special">&amp;</span> <span class="identifier">func</span><span class="special">):</span> <span class="identifier">func_</span><span class="special">(&amp;</span><span class="identifier">func</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">const</span> <span class="keyword">int</span><span class="special">&amp;</span> <span class="identifier">num</span><span class="special">)</span> <span class="special">{</span> <span class="special">(*</span><span class="identifier">func_</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="identifier">interface</span><span class="special">*</span> <span class="identifier">func_</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="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">// Local class for local function.</span>
+ <span class="keyword">struct</span> <span class="identifier">local_add</span> <span class="special">:</span> <span class="identifier">virtual_func</span><span class="special">::</span><span class="identifier">interface</span> <span class="special">{</span>
+ <span class="keyword">explicit</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">const</span> <span class="keyword">int</span><span class="special">&amp;</span> <span class="identifier">_factor</span><span class="special">)</span>
+ <span class="special">:</span> <span class="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">const</span> <span class="keyword">int</span><span class="special">&amp;</span> <span class="identifier">num</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">body</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="keyword">inline</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">call</span><span class="special">(</span><span class="keyword">void</span><span class="special">*</span> <span class="identifier">obj</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">int</span><span class="special">&amp;</span> <span class="identifier">num</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">local_add</span><span class="special">*</span> <span class="identifier">self</span> <span class="special">=</span> <span class="keyword">static_cast</span><span class="special">&lt;</span><span class="identifier">local_add</span><span class="special">*&gt;(</span><span class="identifier">obj</span><span class="special">);</span>
+ <span class="identifier">self</span><span class="special">-&gt;</span><span class="identifier">body</span><span class="special">(</span><span class="identifier">self</span><span class="special">-&gt;</span><span class="identifier">sum_</span><span class="special">,</span> <span class="identifier">self</span><span class="special">-&gt;</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="keyword">int</span><span class="special">&amp;</span> <span class="identifier">sum_</span><span class="special">;</span>
+ <span class="keyword">const</span> <span class="keyword">int</span><span class="special">&amp;</span> <span class="identifier">factor_</span><span class="special">;</span>
+ <span class="keyword">inline</span> <span class="keyword">void</span> <span class="identifier">body</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">const</span> <span class="keyword">int</span><span class="special">&amp;</span> <span class="identifier">factor</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">int</span><span class="special">&amp;</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="special">}</span> <span class="identifier">add_local</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">casting_func</span> <span class="identifier">add_casting</span><span class="special">(&amp;</span><span class="identifier">add_local</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">local_add</span><span class="special">::</span><span class="identifier">call</span><span class="special">);</span>
+ <span class="identifier">virtual_func</span> <span class="identifier">add_virtual</span><span class="special">(</span><span class="identifier">add_local</span><span class="special">);</span>
+
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">v</span><span class="special">(</span><span class="number">10</span><span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">fill</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="number">1</span><span class="special">);</span>
+
+ <span class="comment">// std::for_each(v.begin(), v.end(), add_local); // Error but OK on C++11.</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">add_casting</span><span class="special">);</span> <span class="comment">// OK.</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">add_virtual</span><span class="special">);</span> <span class="comment">// OK.</span>
+
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">sum</span> <span class="special">==</span> <span class="number">200</span><span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span><span class="special">();</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ The casting functor trick measured slightly better run-time performances than
+ the virtual functor trick so the current implementation of this library uses
+ the casting functor trick (probably because in addition to the indirect function
+ call, the virtual functor trick also requires accessing the <a href="http://en.wikipedia.org/wiki/Virtual_method_table" target="_top">virtual
+ function table</a>). However, neither one of the two tricks was observed
+ to allow for compiler optimizations that inline the local function calls (because
+ they rely on one indirect function call via either a function pointer or a
+ virtual function respectively). Therefore, on compilers that accept local classes
+ as template parameters (MSVC, <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a>,
+ etc, see <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm" target="_top">[N2657]</a>
+ and <a href="http://www.boost.org/libs/chrono" target="_top">Boost.Config</a>'s <code class="computeroutput"><span class="identifier">BOOST_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS</span></code>),
+ this library automatically generates code that passes the local class type
+ directly as template parameter without using neither one of these two tricks
+ in order to take full advantage of compiler optimizations that inline the local
+ function calls.
+ </p>
+<h4>
+<a name="boost_localfunction.implementation.h1"></a>
+ <span><a name="boost_localfunction.implementation.parsing_macros"></a></span><a class="link" href="implementation.html#boost_localfunction.implementation.parsing_macros">Parsing
+ Macros</a>
+ </h4>
+<p>
+ This library macros can parse the list of specified parameters and detect if
+ any of the bound variable names matches the token <code class="computeroutput"><span class="identifier">this_</span></code>
+ (to generate special code to bind the object in scope), or if the variable
+ is bound by <code class="computeroutput"><span class="keyword">const</span></code> (to generate
+ special code to bind by constant), etc. The parameter tokens are inspected
+ using preprocessor meta-programming and specifically using the macros defined
+ by the files in the <code class="literal">boost/local_function/detail/preprocessor/keyword/</code>
+ directory. <sup>[<a name="boost_localfunction.implementation.f0" href="#ftn.boost_localfunction.implementation.f0" class="footnote">31</a>]</sup>
+ </p>
+<p>
+ For example, the following code defines a macro that allows the preprocessor
+ to detect if a set of space-separated tokens ends with <code class="computeroutput"><span class="identifier">this_</span></code>
+ or not (see also <a href="../../../example/impl_pp_keyword.cpp" target="_top"><code class="literal">impl_pp_keyword.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">local_function</span><span class="special">/</span><span class="identifier">detail</span><span class="special">/</span><span class="identifier">preprocessor</span><span class="special">/</span><span class="identifier">keyword</span><span class="special">/</span><span class="identifier">thisunderscore</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">local_function</span><span class="special">/</span><span class="identifier">detail</span><span class="special">/</span><span class="identifier">preprocessor</span><span class="special">/</span><span class="identifier">keyword</span><span class="special">/</span><span class="keyword">const</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">local_function</span><span class="special">/</span><span class="identifier">detail</span><span class="special">/</span><span class="identifier">preprocessor</span><span class="special">/</span><span class="identifier">keyword</span><span class="special">/</span><span class="identifier">bind</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">detail</span><span class="special">/</span><span class="identifier">lightweight_test</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="comment">// Expand to 1 if space-separated tokens end with `this_`, 0 otherwise.</span>
+<span class="preprocessor">#define</span> <span class="identifier">IS_THIS_BACK</span><span class="special">(</span><span class="identifier">tokens</span><span class="special">)</span> <span class="special">\</span>
+ <span class="identifier">BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_IS_THISUNDERSCORE_BACK</span><span class="special">(</span> <span class="special">\</span>
+ <span class="identifier">BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_BIND_REMOVE_FRONT</span><span class="special">(</span> <span class="special">\</span>
+ <span class="identifier">BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_CONST_REMOVE_FRONT</span><span class="special">(</span> <span class="special">\</span>
+ <span class="identifier">tokens</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">BOOST_TEST</span><span class="special">(</span><span class="identifier">IS_THIS_BACK</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">this_</span><span class="special">)</span> <span class="special">==</span> <span class="number">1</span><span class="special">);</span>
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">IS_THIS_BACK</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="number">0</span><span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span><span class="special">();</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+<div class="footnotes">
+<br><hr width="100" align="left">
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.implementation.f0" href="#boost_localfunction.implementation.f0" class="para">31</a>] </sup>
+ This technique is at the core of even more complex preprocessor parsing macros
+ like the ones that parse the <a href="http://sourceforge.net/projects/contractpp" target="_top">Contract++</a>
+ syntax.
+ </p></div>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2009-2012 Lorenzo
+ Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="no_variadic_macros.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../reference.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/libs/local_function/doc/html/boost_localfunction/no_variadic_macros.html b/libs/local_function/doc/html/boost_localfunction/no_variadic_macros.html
new file mode 100644
index 000000000..880725443
--- /dev/null
+++ b/libs/local_function/doc/html/boost_localfunction/no_variadic_macros.html
@@ -0,0 +1,265 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Annex: No Variadic Macros</title>
+<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="prev" href="alternatives.html" title="Annex: Alternatives">
+<link rel="next" href="implementation.html" title="Annex: Implementation">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="alternatives.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="implementation.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="section boost_localfunction_no_variadic_macros">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_localfunction.no_variadic_macros"></a><a class="link" href="no_variadic_macros.html" title="Annex: No Variadic Macros">Annex: No Variadic
+ Macros</a>
+</h2></div></div></div>
+<p>
+ This section illustrates an alternative syntax for compilers without variadic
+ macro support.
+ </p>
+<h4>
+<a name="boost_localfunction.no_variadic_macros.h0"></a>
+ <span><a name="boost_localfunction.no_variadic_macros.sequence_syntax"></a></span><a class="link" href="no_variadic_macros.html#boost_localfunction.no_variadic_macros.sequence_syntax">Sequence Syntax</a>
+ </h4>
+<p>
+ Most modern compilers support <a href="http://en.wikipedia.org/wiki/Variadic_macro" target="_top">variaid
+ macros</a> (notably, these include GCC, MSVC, and all <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a>
+ compilers). However, in the rare case that programmers need to use this library
+ on a compiler without variadic macros, this library also allows to specify
+ its macro parameters using a <a href="http://www.boost.org/libs/preprocessor" target="_top">Boost.Preprocessor</a>
+ sequence where tokens are separated by round parenthesis <code class="computeroutput"><span class="special">()</span></code>:
+ </p>
+<pre class="programlisting"><span class="special">(</span><span class="identifier">token1</span><span class="special">)</span> <span class="special">(</span><span class="identifier">token2</span><span class="special">)</span> <span class="special">...</span> <span class="comment">// All compilers.</span>
+</pre>
+<p>
+ Instead of the comma-separated list that we have seen so far which requires
+ variadic macros:
+ </p>
+<pre class="programlisting"><span class="identifier">token1</span><span class="special">,</span> <span class="identifier">token2</span><span class="special">,</span> <span class="special">...</span> <span class="comment">// Only compilers with varidic macros.</span>
+</pre>
+<p>
+ For example, the following syntax is accepted on all compilers with and without
+ variadic macros (see also <a href="../../../test/add_seq.cpp" target="_top"><code class="literal">add_seq.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><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="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">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">factor</span><span class="special">)</span> <span class="special">(</span><span class="identifier">bind</span><span class="special">&amp;</span> <span class="identifier">sum</span><span class="special">)</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="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="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="identifier">BOOST_TEST</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="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span><span class="special">();</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ However, on compilers with variadic macros the comma-separated syntax we have
+ seen so far is preferred because more readable (see also <a href="../../../test/add.cpp" target="_top"><code class="literal">add.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><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="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_TEST</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="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span><span class="special">();</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ Note that the same macros accept both syntaxes on compilers with variadic macros
+ and only the sequence syntax on compilers without variadic macros. Finally,
+ an empty local function parameter list is always specified using <code class="computeroutput"><span class="keyword">void</span></code> on compilers with and without variadic
+ macros:
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// No parameter.</span>
+ <span class="keyword">return</span> <span class="number">10</span><span class="special">;</span>
+<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">ten</span><span class="special">)</span>
+
+<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">ten</span><span class="special">()</span> <span class="special">==</span> <span class="number">10</span><span class="special">);</span>
+</pre>
+<p>
+ </p>
+<h4>
+<a name="boost_localfunction.no_variadic_macros.h1"></a>
+ <span><a name="boost_localfunction.no_variadic_macros.examples"></a></span><a class="link" href="no_variadic_macros.html#boost_localfunction.no_variadic_macros.examples">Examples</a>
+ </h4>
+<p>
+ For reference, the following is a list of most of the examples presented in
+ this documentation reprogrammed using the sequence syntax instead of the comma-separated
+ syntax (in alphabetic order):
+ </p>
+<div class="informaltable"><table class="table">
+<colgroup><col></colgroup>
+<thead><tr><th>
+ <p>
+ Files
+ </p>
+ </th></tr></thead>
+<tbody>
+<tr><td>
+ <p>
+ <a href="../../../test/add_classifiers_seq.cpp" target="_top"><code class="literal">add_classifiers_seq.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/add_default_seq.cpp" target="_top"><code class="literal">add_default_seq.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/add_except_seq.cpp" target="_top"><code class="literal">add_except_seq.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/add_inline_seq.cpp" target="_top"><code class="literal">add_inline_seq.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/add_params_only_seq.cpp" target="_top"><code class="literal">add_params_only_seq.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/add_template_seq.cpp" target="_top"><code class="literal">add_template_seq.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/add_this_seq.cpp" target="_top"><code class="literal">add_this_seq.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/add_typed_seq.cpp" target="_top"><code class="literal">add_typed_seq.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/add_with_default_seq.cpp" target="_top"><code class="literal">add_with_default_seq.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/all_decl_seq.cpp" target="_top"><code class="literal">all_decl_seq.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/factorial_seq.cpp" target="_top"><code class="literal">factorial_seq.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/macro_commas_seq.cpp" target="_top"><code class="literal">macro_commas_seq.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/nesting_seq.cpp" target="_top"><code class="literal">nesting_seq.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/overload_seq.cpp" target="_top"><code class="literal">overload_seq.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/return_assign_seq.cpp" target="_top"><code class="literal">return_assign_seq.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/return_derivative_seq.cpp" target="_top"><code class="literal">return_derivative_seq.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/return_inc_seq.cpp" target="_top"><code class="literal">return_inc_seq.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/return_setget_seq.cpp" target="_top"><code class="literal">return_setget_seq.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/return_this_seq.cpp" target="_top"><code class="literal">return_this_seq.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/same_line_seq.cpp" target="_top"><code class="literal">same_line_seq.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/transform_seq.cpp" target="_top"><code class="literal">transform_seq.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/typeof_seq.cpp" target="_top"><code class="literal">typeof_seq.cpp</code></a>
+ </p>
+ </td></tr>
+<tr><td>
+ <p>
+ <a href="../../../test/typeof_template_seq.cpp" target="_top"><code class="literal">typeof_template_seq.cpp</code></a>
+ </p>
+ </td></tr>
+</tbody>
+</table></div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2009-2012 Lorenzo
+ Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="alternatives.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="implementation.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/libs/local_function/doc/html/boost_localfunction/release_notes.html b/libs/local_function/doc/html/boost_localfunction/release_notes.html
new file mode 100644
index 000000000..591db0308
--- /dev/null
+++ b/libs/local_function/doc/html/boost_localfunction/release_notes.html
@@ -0,0 +1,168 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Release Notes</title>
+<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="prev" href="../BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS">
+<link rel="next" href="bibliography.html" title="Bibliography">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="../BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="bibliography.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="section boost_localfunction_release_notes">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_localfunction.release_notes"></a><a class="link" href="release_notes.html" title="Release Notes">Release Notes</a>
+</h2></div></div></div>
+<p>
+ This section lists the major changes between different library releases (in
+ chronological order).
+ </p>
+<h4>
+<a name="boost_localfunction.release_notes.h0"></a>
+ <span><a name="boost_localfunction.release_notes.version_1_0_0__2012_04_12_"></a></span><a class="link" href="release_notes.html#boost_localfunction.release_notes.version_1_0_0__2012_04_12_">Version
+ 1.0.0 (2012-04-12)</a>
+ </h4>
+<div class="orderedlist"><ol class="orderedlist" type="1">
+<li class="listitem">
+ Incorporated all comments from the <a href="http://lists.boost.org/boost-announce/2011/12/0340.php" target="_top">Boost
+ review of this library</a>.
+ </li>
+<li class="listitem">
+ Removed local blocks and local exits.
+ </li>
+<li class="listitem">
+ Renamed the library from Boost.Local to Boost.LocalFunction.
+ </li>
+<li class="listitem">
+ Using <code class="computeroutput"><span class="identifier">this_</span></code> instead of
+ <code class="computeroutput"><span class="keyword">this</span></code> also in the local function
+ declaration (not just the body).
+ </li>
+<li class="listitem">
+ Made changes that allow to return local functions (similar to closures).
+ </li>
+<li class="listitem">
+ Added GCC lambda and constant block examples.
+ </li>
+<li class="listitem">
+ Moved <code class="computeroutput"><span class="identifier">overloaded_function</span></code>
+ to Boost.Functional/OverloadedFunction.
+ </li>
+<li class="listitem">
+ Moved <code class="computeroutput"><span class="identifier">BOOST_IDENTITY_TYPE</span></code>
+ to Boost.Utility/IdentityType.
+ </li>
+<li class="listitem">
+ Completely removed use of Boost.Typeof when bound and result types are
+ explicitly specified.
+ </li>
+<li class="listitem">
+ Added <code class="computeroutput"><span class="special">...</span><span class="identifier">_ID</span></code>
+ macros for multiple expansions on the same line.
+ </li>
+<li class="listitem">
+ Fixed compilation on Boost regression test platforms.
+ </li>
+</ol></div>
+<h4>
+<a name="boost_localfunction.release_notes.h1"></a>
+ <span><a name="boost_localfunction.release_notes.version_0_2_0__2011_05_14_"></a></span><a class="link" href="release_notes.html#boost_localfunction.release_notes.version_0_2_0__2011_05_14_">Version
+ 0.2.0 (2011-05-14)</a>
+ </h4>
+<div class="orderedlist"><ol class="orderedlist" type="1">
+<li class="listitem">
+ Replaced parenthesized syntax with variadic and sequencing macro syntaxes.
+ </li>
+<li class="listitem">
+ Profiled library performances against other approaches.
+ </li>
+<li class="listitem">
+ Replaced virtual functor trick with casting functor trick (for smaller
+ run-time).
+ </li>
+<li class="listitem">
+ Optimized library run-time (rearranging code and not using casting functor
+ trick on compilers that accept local classes as template parameters).
+ </li>
+<li class="listitem">
+ Supported inline and recursive local functions.
+ </li>
+<li class="listitem">
+ Added type-of macro to expose bound types.
+ </li>
+<li class="listitem">
+ Allowed to explicitly specify bound types.
+ </li>
+<li class="listitem">
+ Removed using <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span></code> instead of exposing internal
+ local functor as public API.
+ </li>
+<li class="listitem">
+ Added functor to overload local functions (and functors in general).
+ </li>
+<li class="listitem">
+ Implemented support for nesting local functions, blocks, and exits into
+ one another.
+ </li>
+</ol></div>
+<h4>
+<a name="boost_localfunction.release_notes.h2"></a>
+ <span><a name="boost_localfunction.release_notes.version_0_1_1__2011_01_10_"></a></span><a class="link" href="release_notes.html#boost_localfunction.release_notes.version_0_1_1__2011_01_10_">Version
+ 0.1.1 (2011-01-10)</a>
+ </h4>
+<div class="orderedlist"><ol class="orderedlist" type="1">
+<li class="listitem">
+ Uploaded library source into Boost SVN sandbox.
+ </li>
+<li class="listitem">
+ Fixed prev/next arrows and other minor layouts in documentation.
+ </li>
+<li class="listitem">
+ Added Release section to documentation.
+ </li>
+</ol></div>
+<h4>
+<a name="boost_localfunction.release_notes.h3"></a>
+ <span><a name="boost_localfunction.release_notes.version_0_1_0__2011_01_03_"></a></span><a class="link" href="release_notes.html#boost_localfunction.release_notes.version_0_1_0__2011_01_03_">Version
+ 0.1.0 (2011-01-03)</a>
+ </h4>
+<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
+ Shared with Boost for first round of comments.
+ </li></ol></div>
+<h4>
+<a name="boost_localfunction.release_notes.h4"></a>
+ <span><a name="boost_localfunction.release_notes.version_0_0_1__2010_12_15_"></a></span><a class="link" href="release_notes.html#boost_localfunction.release_notes.version_0_0_1__2010_12_15_">Version
+ 0.0.1 (2010-12-15)</a>
+ </h4>
+<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
+ Completed development, examples, and documentation.
+ </li></ol></div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2009-2012 Lorenzo
+ Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="../BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="bibliography.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/libs/local_function/doc/html/boost_localfunction/tutorial.html b/libs/local_function/doc/html/boost_localfunction/tutorial.html
new file mode 100644
index 000000000..8b65aa703
--- /dev/null
+++ b/libs/local_function/doc/html/boost_localfunction/tutorial.html
@@ -0,0 +1,540 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Tutorial</title>
+<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="prev" href="getting_started.html" title="Getting Started">
+<link rel="next" href="advanced_topics.html" title="Advanced Topics">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center"><a href="../../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="getting_started.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="advanced_topics.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="section boost_localfunction_tutorial">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_localfunction.tutorial"></a><a class="link" href="tutorial.html" title="Tutorial">Tutorial</a>
+</h2></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"><a href="tutorial.html#boost_localfunction.tutorial.local_functions">Local Functions</a></span></dt>
+<dt><span class="section"><a href="tutorial.html#boost_localfunction.tutorial.Binding">Binding Variables</a></span></dt>
+<dt><span class="section"><a href="tutorial.html#boost_localfunction.tutorial.binding_the_object__this_">Binding
+ the Object <code class="computeroutput"><span class="keyword">this</span></code></a></span></dt>
+<dt><span class="section"><a href="tutorial.html#boost_localfunction.tutorial.templates">Templates</a></span></dt>
+</dl></div>
+<p>
+ This section illustrates basic usage of this library.
+ </p>
+<div class="section boost_localfunction_tutorial_local_functions">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.tutorial.local_functions"></a><a class="link" href="tutorial.html#boost_localfunction.tutorial.local_functions" title="Local Functions">Local Functions</a>
+</h3></div></div></div>
+<p>
+ Local functions are defined using macros from the header file <code class="computeroutput"><a class="link" href="../reference.html#header.boost.local_function_hpp" title="Header &lt;boost/local_function.hpp&gt;">boost/local_function.hpp</a></code>. The
+ macros must be used from within a declarative context (this is a limitation
+ with respect to <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a> which can instead be declared also within expressions):
+ </p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">local_function</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span> <span class="comment">// This library header.</span>
+
+<span class="special">...</span>
+<span class="special">{</span> <span class="comment">// Some declarative context.</span>
+ <span class="special">...</span>
+ <span class="emphasis"><em>result-type</em></span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="emphasis"><em>parameters</em></span><span class="special">)</span> <span class="special">{</span>
+ <span class="emphasis"><em>body-code</em></span>
+ <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="emphasis"><em>name</em></span><span class="special">)</span>
+ <span class="special">...</span>
+<span class="special">}</span>
+</pre>
+<p>
+ The code expanded by the macros declares a function object (or <a href="http://en.wikipedia.org/wiki/Functor" target="_top">functor</a>)
+ with the local function name specified by <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code>.
+ <sup>[<a name="boost_localfunction.tutorial.local_functions.f0" href="#ftn.boost_localfunction.tutorial.local_functions.f0" class="footnote">5</a>]</sup> The usual C++ scope visibility rules apply to local functions
+ for which a local function is visible only within the enclosing scope in
+ which it is declared.
+ </p>
+<p>
+ The local function result type is specified just before the <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code>
+ macro.
+ </p>
+<p>
+ The local function body is specified using the usual C++ statement syntax
+ in a code block <code class="computeroutput"><span class="special">{</span> <span class="special">...</span>
+ <span class="special">}</span></code> between the <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code>
+ and <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code>
+ macros. The body is specified outside any of the macros so eventual compiler
+ error messages and related line numbers retain their usual meaning and format.
+ <sup>[<a name="boost_localfunction.tutorial.local_functions.f1" href="#ftn.boost_localfunction.tutorial.local_functions.f1" class="footnote">6</a>]</sup>
+ </p>
+<p>
+ The local function parameters are passed to the <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code>
+ macro as a comma-separated list of tokens (see the <a class="link" href="no_variadic_macros.html" title="Annex: No Variadic Macros">No
+ Variadic Macros</a> section for compilers that do not support variadic
+ macros):
+ </p>
+<pre class="programlisting"><span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><code class="literal"><span class="emphasis"><em>parameter-type1 parameter-name1</em></span></code><span class="special">,</span> <code class="literal"><span class="emphasis"><em>parameter-type2 parameter-name2, ...</em></span></code><span class="special">)</span>
+</pre>
+<p>
+ The maximum number of parameters that can be passed to a local function is
+ controlled at compile-time by the configuration macro <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>.
+ For example, let's program a local function named <code class="computeroutput"><span class="identifier">add</span></code>
+ that adds together two integers <code class="computeroutput"><span class="identifier">x</span></code>
+ and <code class="computeroutput"><span class="identifier">y</span></code> (see also <a href="../../../test/add_params_only.cpp" target="_top"><code class="literal">add_params_only.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">y</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Local function.</span>
+ <span class="keyword">return</span> <span class="identifier">x</span> <span class="special">+</span> <span class="identifier">y</span><span class="special">;</span>
+<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">add</span><span class="special">)</span>
+
+<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">add</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="number">2</span><span class="special">)</span> <span class="special">==</span> <span class="number">3</span><span class="special">);</span> <span class="comment">// Local function call.</span>
+</pre>
+<p>
+ </p>
+<p>
+ If the local function has no parameter, it is possible to pass <code class="computeroutput"><span class="keyword">void</span></code> to the <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code>
+ macro (similarly to the C++ syntax that allows to use <code class="literal"><span class="emphasis"><em>result-type
+ function-name</em></span></code><code class="computeroutput"><span class="special">(</span><span class="keyword">void</span><span class="special">)</span></code> to declare
+ a function with no parameter): <sup>[<a name="boost_localfunction.tutorial.local_functions.f2" href="#ftn.boost_localfunction.tutorial.local_functions.f2" class="footnote">7</a>]</sup>
+ </p>
+<pre class="programlisting"><span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="comment">// No parameter.</span>
+</pre>
+<p>
+ For example, let's program a local function that always returns <code class="computeroutput"><span class="number">10</span></code> (see also <a href="../../../test/ten_void.cpp" target="_top"><code class="literal">ten_void.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// No parameter.</span>
+ <span class="keyword">return</span> <span class="number">10</span><span class="special">;</span>
+<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">ten</span><span class="special">)</span>
+
+<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">ten</span><span class="special">()</span> <span class="special">==</span> <span class="number">10</span><span class="special">);</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="section boost_localfunction_tutorial_Binding">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.tutorial.Binding"></a><a class="link" href="tutorial.html#boost_localfunction.tutorial.Binding" title="Binding Variables">Binding Variables</a>
+</h3></div></div></div>
+<p>
+ Variables in scope (local variables, enclosing function parameters, data
+ members, etc) can be bound to a local function declaration. Only bound variables,
+ static variables, global variables, functions, and enumerations from the
+ enclosing scope are accessible from within the local function body. The types
+ of bound variables are deduced automatically by this library using <a href="http://www.boost.org/libs/typeof" target="_top">Boost.Typeof</a>. <sup>[<a name="boost_localfunction.tutorial.Binding.f0" href="#ftn.boost_localfunction.tutorial.Binding.f0" class="footnote">8</a>]</sup>
+ </p>
+<p>
+ This library introduces the new "keyword" <code class="computeroutput"><span class="identifier">bind</span></code>
+ <sup>[<a name="boost_localfunction.tutorial.Binding.f1" href="#ftn.boost_localfunction.tutorial.Binding.f1" class="footnote">9</a>]</sup> which is used in place of the parameter type to specify the name
+ of a variable in scope to bind (therefore, <code class="computeroutput"><span class="identifier">bind</span></code>
+ cannot be used as a local function parameter type). A variable can be bound
+ by value:
+ </p>
+<pre class="programlisting"><span class="identifier">bind</span> <span class="emphasis"><em>variable-name</em></span> <span class="comment">// Bind by value.</span>
+</pre>
+<p>
+ Or by reference prefixing the variable name with <code class="computeroutput"><span class="special">&amp;</span></code>:
+ </p>
+<pre class="programlisting"><span class="identifier">bind</span><span class="special">&amp;</span> <span class="emphasis"><em>variable-name</em></span> <span class="comment">// Bind by reference.</span>
+</pre>
+<p>
+ Furthermore, the "keyword" <code class="computeroutput"><span class="identifier">bind</span></code>
+ can be prefixed by <code class="computeroutput"><span class="keyword">const</span></code> to
+ bind the variable by constant value:
+ </p>
+<pre class="programlisting"><span class="keyword">const</span> <span class="identifier">bind</span> <span class="emphasis"><em>variable-name</em></span> <span class="comment">// Bind by constant value.</span>
+</pre>
+<p>
+ Or by constant reference:
+ </p>
+<pre class="programlisting"><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">&amp;</span> <span class="emphasis"><em>variable-name</em></span> <span class="comment">// Bind by constant value.</span>
+</pre>
+<p>
+ Note that when <code class="computeroutput"><span class="keyword">const</span></code> is used,
+ it must always precede <code class="computeroutput"><span class="identifier">bind</span></code>.
+ <sup>[<a name="boost_localfunction.tutorial.Binding.f2" href="#ftn.boost_localfunction.tutorial.Binding.f2" class="footnote">10</a>]</sup>
+ </p>
+<p>
+ If a variable is bound by value, then a copy of the variable value is taken
+ at the point of the local function declaration. If a variable is bound by
+ reference instead, the variable will refer to the value it has at the point
+ of the local function call. Furthermore, it is the programmers' responsibility
+ to ensure that variables bound by reference survive the existence scope of
+ the local function otherwise the bound references will be invalid when the
+ local function is called resulting in undefined behaviour (in other words,
+ the usual care in using C++ references must be taken for variables bound
+ by reference).
+ </p>
+<p>
+ The type of a bound variable is automatically deduced using <a href="http://www.boost.org/libs/typeof" target="_top">Boost.Typeof</a>
+ and it is the exact same type used to declare such a variable in the enclosing
+ scope with the following notes:
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+ If a bound variable was declared constant in the enclosing scope, it
+ will always be bound by constant value or constant reference even if
+ <code class="computeroutput"><span class="identifier">bind</span><span class="special">...</span></code>
+ is used instead of <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">...</span></code>
+ . However, if a bound variable was not declared constant in the enclosing
+ scope then it will not be bound as constant unless constant binding is
+ forced using <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">...</span></code>. (Note that binding by constant reference
+ is not supported by <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a> but it is supported by this library.) <sup>[<a name="boost_localfunction.tutorial.Binding.f3" href="#ftn.boost_localfunction.tutorial.Binding.f3" class="footnote">11</a>]</sup>
+ </li>
+<li class="listitem">
+ If a bound variable was declared as a reference in the enclosing scope,
+ it will still be bound by value unless it is explicitly bound by reference
+ using <code class="computeroutput"><span class="identifier">bind</span><span class="special">&amp;</span></code>
+ or <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">&amp;</span></code>. <sup>[<a name="boost_localfunction.tutorial.Binding.f4" href="#ftn.boost_localfunction.tutorial.Binding.f4" class="footnote">12</a>]</sup>
+ </li>
+</ul></div>
+<p>
+ When a variable is bound by value (constant or not), its type must be <a href="http://www.boost.org/doc/libs/release/doc/html/CopyConstructible.html" target="_top"><code class="computeroutput"><span class="identifier">CopyConstructible</span></code></a> (i.e., its must
+ provide a copy constructor). As with passing parameters to usual C++ functions,
+ programmers might want to bind variables of complex types by (possibly constant)
+ reference instead of by value to avoid expensive copy operations when these
+ variables are bound to a local function.
+ </p>
+<p>
+ For example, let's program the local function <code class="computeroutput"><span class="identifier">add</span></code>
+ from the example in the <a class="link" href="../index.html#boost_localfunction.introduction" title="Introduction">Introduction</a>
+ section. We bind the local variable <code class="computeroutput"><span class="identifier">factor</span></code>
+ by constant value (because its value should not be modified by the local
+ function), the local variable <code class="computeroutput"><span class="identifier">sum</span></code>
+ by non-constant reference (because its value needs to be updated with the
+ summation result), and program the body to perform the summation (see also
+ <a href="../../../test/add.cpp" target="_top"><code class="literal">add.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><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="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_TEST</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="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span><span class="special">();</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="section boost_localfunction_tutorial_binding_the_object__this_">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.tutorial.binding_the_object__this_"></a><a class="link" href="tutorial.html#boost_localfunction.tutorial.binding_the_object__this_" title="Binding the Object this">Binding
+ the Object <code class="computeroutput"><span class="keyword">this</span></code></a>
+</h3></div></div></div>
+<p>
+ It is also possible to bind the object <code class="computeroutput"><span class="keyword">this</span></code>
+ when it is in scope (e.g., from an enclosing non-static member function).
+ This is done by using the special symbol <code class="computeroutput"><span class="identifier">this_</span></code>
+ (instead of <code class="computeroutput"><span class="keyword">this</span></code>) as the name
+ of the variable to bind in the local function declaration and also to access
+ the object within the local function body. <sup>[<a name="boost_localfunction.tutorial.binding_the_object__this_.f0" href="#ftn.boost_localfunction.tutorial.binding_the_object__this_.f0" class="footnote">13</a>]</sup>
+ </p>
+<div class="warning"><table border="0" summary="Warning">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../doc/src/images/warning.png"></td>
+<th align="left">Warning</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ The library will generate a compile-time error if <code class="computeroutput"><span class="keyword">this</span></code>
+ is mistakenly used instead of <code class="computeroutput"><span class="identifier">this_</span></code>
+ to bind the object in the local function declaration. However, mistakenly
+ using <code class="computeroutput"><span class="keyword">this</span></code> instead of <code class="computeroutput"><span class="identifier">this_</span></code> to access the object within the
+ local function body will leads to undefined behaviour and it will not necessarily
+ generate a compile-time error. <sup>[<a name="boost_localfunction.tutorial.binding_the_object__this_.f1" href="#ftn.boost_localfunction.tutorial.binding_the_object__this_.f1" class="footnote">14</a>]</sup> Programmers are ultimately responsible to make sure that <code class="computeroutput"><span class="keyword">this</span></code> is never used within a local function.
+ </p></td></tr>
+</table></div>
+<p>
+ The object <code class="computeroutput"><span class="keyword">this</span></code> can be bound
+ by value:
+ </p>
+<pre class="programlisting"><span class="identifier">bind</span> <span class="identifier">this_</span> <span class="comment">// Bind the object `this` by value.</span>
+</pre>
+<p>
+ In this case the local function will be able to modify the object when the
+ enclosing scope is not a constant member and it will not be able to modify
+ the object when the enclosing scope is a constant member. Otherwise, the
+ object <code class="computeroutput"><span class="keyword">this</span></code> can be bound by
+ constant value:
+ </p>
+<pre class="programlisting"><span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">this_</span> <span class="comment">// Bind the object `this` by constant value.</span>
+</pre>
+<p>
+ In this case the local function will never be able to modify the object (regardless
+ of whether the enclosing scope is a constant member or not).
+ </p>
+<p>
+ Note that the object <code class="computeroutput"><span class="keyword">this</span></code> can
+ never be bound by reference because C++ does not allow to obtain a reference
+ to <code class="computeroutput"><span class="keyword">this</span></code> (the library will generate
+ a compile-time error if programmers try to use <code class="computeroutput"><span class="identifier">bind</span><span class="special">&amp;</span> <span class="identifier">this_</span></code>
+ or <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">&amp;</span> <span class="identifier">this_</span></code>).
+ Note that <code class="computeroutput"><span class="keyword">this</span></code> is a pointer
+ so the pointed object is never copied even if <code class="computeroutput"><span class="keyword">this</span></code>
+ is bound by value (also it is not possible to directly bind <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> because
+ <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
+ is an expression and not a variable name).
+ </p>
+<p>
+ For example, let's program a local function <code class="computeroutput"><span class="identifier">add</span></code>
+ similar to the one in the example from the <a class="link" href="../index.html#boost_localfunction.introduction" title="Introduction">Introduction</a>
+ section but using a member function to illustrate how to bind the object
+ <code class="computeroutput"><span class="keyword">this</span></code> (see also <a href="../../../test/add_this.cpp" target="_top"><code class="literal">add_this.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">adder</span> <span class="special">{</span>
+ <span class="identifier">adder</span><span class="special">()</span> <span class="special">:</span> <span class="identifier">sum_</span><span class="special">(</span><span class="number">0</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="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;&amp;</span> <span class="identifier">nums</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">)</span> <span class="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="identifier">factor</span><span class="special">,</span> <span class="identifier">bind</span> <span class="identifier">this_</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">this_</span><span class="special">-&gt;</span><span class="identifier">sum_</span> <span class="special">+=</span> <span class="identifier">factor</span> <span class="special">*</span> <span class="identifier">num</span><span class="special">;</span> <span class="comment">// Use `this_` instead of `this`.</span>
+ <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">add</span><span class="special">)</span>
+
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">nums</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">nums</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">add</span><span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">sum_</span><span class="special">;</span>
+ <span class="special">}</span>
+
+<span class="keyword">private</span><span class="special">:</span>
+ <span class="keyword">int</span> <span class="identifier">sum_</span><span class="special">;</span>
+<span class="special">};</span>
+</pre>
+<p>
+ </p>
+<p>
+ Note that the local function has access to all class members via the bound
+ object <code class="computeroutput"><span class="identifier">this_</span></code> regardless of
+ their access level (<code class="computeroutput"><span class="keyword">public</span></code>,
+ <code class="computeroutput"><span class="keyword">protected</span></code>, or <code class="computeroutput"><span class="keyword">private</span></code>). <sup>[<a name="boost_localfunction.tutorial.binding_the_object__this_.f2" href="#ftn.boost_localfunction.tutorial.binding_the_object__this_.f2" class="footnote">15</a>]</sup> Specifically, in the example above the local function updates
+ the private data member <code class="computeroutput"><span class="identifier">sum_</span></code>.
+ </p>
+</div>
+<div class="section boost_localfunction_tutorial_templates">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_localfunction.tutorial.templates"></a><a class="link" href="tutorial.html#boost_localfunction.tutorial.templates" title="Templates">Templates</a>
+</h3></div></div></div>
+<p>
+ When local functions are programmed within templates, they need to be declared
+ using the special macros <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_TPL">BOOST_LOCAL_FUNCTION_TPL</a></code>
+ and <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_NAME_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_NAME_TPL">BOOST_LOCAL_FUNCTION_NAME_TPL</a></code>:
+ <sup>[<a name="boost_localfunction.tutorial.templates.f0" href="#ftn.boost_localfunction.tutorial.templates.f0" class="footnote">16</a>]</sup>
+ </p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">local_function</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span> <span class="comment">// This library header.</span>
+
+<span class="special">...</span>
+<span class="special">{</span> <span class="comment">// Some declarative context within a template.</span>
+ <span class="special">...</span>
+ <span class="emphasis"><em>result-type</em></span> <span class="identifier">BOOST_LOCAL_FUNCTION_TPL</span><span class="special">(</span><span class="emphasis"><em>parameters</em></span><span class="special">)</span> <span class="special">{</span>
+ <span class="emphasis"><em>body-code</em></span>
+ <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME_TPL</span><span class="special">(</span><span class="emphasis"><em>name</em></span><span class="special">)</span>
+ <span class="special">...</span>
+<span class="special">}</span>
+</pre>
+<p>
+ The <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_TPL">BOOST_LOCAL_FUNCTION_TPL</a></code>
+ and <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_NAME_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_NAME_TPL">BOOST_LOCAL_FUNCTION_NAME_TPL</a></code>
+ macros have the exact same syntax of the <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code>
+ and <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code>
+ macros that we have seen so far.
+ </p>
+<p>
+ For example, let's program a local function similar to the one from the
+ <a class="link" href="../index.html#boost_localfunction.introduction" title="Introduction">Introduction</a> section
+ but within a template (see also <a href="../../../test/add_template.cpp" target="_top"><code class="literal">add_template.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">&gt;</span>
+<span class="identifier">T</span> <span class="identifier">total</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">T</span><span class="special">&amp;</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">T</span><span class="special">&amp;</span> <span class="identifier">y</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">T</span><span class="special">&amp;</span> <span class="identifier">z</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">T</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="identifier">T</span><span class="special">(),</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span>
+
+ <span class="comment">// Must use the `..._TPL` macros within templates.</span>
+ <span class="identifier">T</span> <span class="identifier">BOOST_LOCAL_FUNCTION_TPL</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="identifier">T</span> <span class="identifier">num</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">return</span> <span class="identifier">sum</span> <span class="special">+=</span> <span class="identifier">factor</span> <span class="special">*</span> <span class="identifier">num</span><span class="special">;</span>
+ <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME_TPL</span><span class="special">(</span><span class="identifier">add</span><span class="special">)</span>
+
+ <span class="identifier">add</span><span class="special">(</span><span class="identifier">x</span><span class="special">);</span>
+ <span class="identifier">T</span> <span class="identifier">nums</span><span class="special">[</span><span class="number">2</span><span class="special">];</span> <span class="identifier">nums</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="special">=</span> <span class="identifier">y</span><span class="special">;</span> <span class="identifier">nums</span><span class="special">[</span><span class="number">1</span><span class="special">]</span> <span class="special">=</span> <span class="identifier">z</span><span class="special">;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">nums</span><span class="special">,</span> <span class="identifier">nums</span> <span class="special">+</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">add</span><span class="special">);</span>
+
+ <span class="keyword">return</span> <span class="identifier">sum</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="footnotes">
+<br><hr width="100" align="left">
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.tutorial.local_functions.f0" href="#boost_localfunction.tutorial.local_functions.f0" class="para">5</a>] </sup>
+ <span class="bold"><strong>Rationale.</strong></span> The local function name must
+ be passed to the macro <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code>
+ ending the function definition so this macro can declare a local variable
+ with the local function name to hold the local function object. Therefore
+ the local function name cannot be specified within the <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code>
+ and it must appear instead after the local function body (even if that
+ differs from the usual C++ function declaration syntax).
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.tutorial.local_functions.f1" href="#boost_localfunction.tutorial.local_functions.f1" class="para">6</a>] </sup>
+ <span class="bold"><strong>Rationale.</strong></span> If the local function body
+ were instead passed as a macro parameter, it would be expanded on a single
+ line of code (because macros always expand as a single line of code). Therefore,
+ eventual compiler error line numbers would all report the same value and
+ would no longer be useful to pinpoint errors.
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.tutorial.local_functions.f2" href="#boost_localfunction.tutorial.local_functions.f2" class="para">7</a>] </sup>
+ <span class="bold"><strong>Rationale.</strong></span> The <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/standards" target="_top">C++03</a>
+ standard does not allow to pass empty parameters to a macro so the macro
+ cannot be invoked as <code class="computeroutput"><span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">()</span></code>. On <a href="http://www.open-std.org/jtc1/sc22/wg14/www/projects#9899" target="_top">C99</a>
+ compilers with properly implemented empty macro parameter support, it would
+ be possible to allow <code class="computeroutput"><span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">()</span></code> but this is already not the case for
+ MSVC so this syntax is never allowed to ensure better portability.
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.tutorial.Binding.f0" href="#boost_localfunction.tutorial.Binding.f0" class="para">8</a>] </sup>
+ <span class="bold"><strong>Rationale.</strong></span> By binding a variable in scope,
+ the local function declaration is specifying that such a variable should
+ be accessible within the local function body regardless of its type. Semantically,
+ this binding should be seen as an "extension" of the scope of
+ the bound variable from the enclosing scope to the scope of the local function
+ body. Therefore, contrary to the semantic of passing a function parameter,
+ the semantic of binding a variable does not depend on the variable type
+ but just on the variable name: "The variable in scope named <span class="emphasis"><em>x</em></span>
+ should be accessible within the local function named <span class="emphasis"><em>f</em></span>".
+ For example, this reduces maintenance because if a bound variable type
+ is changed, the local function declaration does not have to change.
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.tutorial.Binding.f1" href="#boost_localfunction.tutorial.Binding.f1" class="para">9</a>] </sup>
+ Obviously, the token <code class="computeroutput"><span class="identifier">bind</span></code>
+ is not a keyword of the C++ language. This library parses the token <code class="computeroutput"><span class="identifier">bind</span></code> during macro expansion using preprocessor
+ meta-programming (see the <a class="link" href="implementation.html" title="Annex: Implementation">Implementation</a>
+ section). Therefore, <code class="computeroutput"><span class="identifier">bind</span></code>
+ can be considered a new "keyword" only at the preprocessor meta-programming
+ level within the syntax defined by the macros of this library (thus it
+ is referred to as a "keyword" only within quotes).
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.tutorial.Binding.f2" href="#boost_localfunction.tutorial.Binding.f2" class="para">10</a>] </sup>
+ <span class="bold"><strong>Rationale.</strong></span> The library macros could have
+ been implemented to accept both syntaxes <code class="computeroutput"><span class="keyword">const</span>
+ <span class="identifier">bind</span> <span class="special">...</span></code>
+ and <code class="computeroutput"><span class="identifier">bind</span> <span class="keyword">const</span>
+ <span class="special">...</span></code> equivalently. However, handling
+ both syntaxes would have complicated the macro implementation without adding
+ any feature so only one syntax <code class="computeroutput"><span class="keyword">const</span>
+ <span class="identifier">bind</span> <span class="special">...</span></code>
+ is supported.
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.tutorial.Binding.f3" href="#boost_localfunction.tutorial.Binding.f3" class="para">11</a>] </sup>
+ An historical note: Constant binding of variables in scope was the
+ main use case that originally motivated the authors in developing this
+ library. The authors needed to locally create a chuck of code to assert
+ some correctness conditions while these assertions were not supposed
+ to modify any of the variables they were using (see the <a href="http://sourceforge.net/projects/contractpp" target="_top">Contract++</a>
+ library). This was achieved by binding by constant reference <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">&amp;</span></code> the variables needed by the assertions
+ and then by programming the local function body to check the assertions.
+ This way if any of the assertions mistakenly changes a bound variable
+ (for example confusing the operator <code class="computeroutput"><span class="special">==</span></code>
+ with <code class="computeroutput"><span class="special">=</span></code>), the compiler
+ correctly generates an error because the bound variable is of <code class="computeroutput"><span class="keyword">const</span></code> type within the local function
+ body (see also <span class="emphasis"><em>constant blocks</em></span> in the <a class="link" href="examples.html" title="Examples">Examples</a>
+ section).
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.tutorial.Binding.f4" href="#boost_localfunction.tutorial.Binding.f4" class="para">12</a>] </sup>
+ <span class="bold"><strong>Rationale.</strong></span> Variables originally declared
+ as references are bound by value unless <code class="computeroutput"><span class="special">[</span><span class="keyword">const</span><span class="special">]</span> <span class="identifier">bind</span><span class="special">&amp;</span></code>
+ is used so that references can be bound by both value <code class="computeroutput"><span class="special">[</span><span class="keyword">const</span><span class="special">]</span> <span class="identifier">bind</span></code>
+ and reference <code class="computeroutput"><span class="special">[</span><span class="keyword">const</span><span class="special">]</span> <span class="identifier">bind</span><span class="special">&amp;</span></code> (this is the same binding semantic
+ adopted by <a href="http://www.boost.org/libs/scope_exit" target="_top">Boost.ScopeExit</a>).
+ However, variables originally declared as constants should never loose
+ their <code class="computeroutput"><span class="keyword">const</span></code> qualifier
+ (to prevent their modification not just in the enclosing scope but
+ also in the local scope) thus they are always bound by constant even
+ if <code class="computeroutput"><span class="identifier">bind</span><span class="special">[&amp;]</span></code>
+ is used instead of <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">[&amp;]</span></code>.
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.tutorial.binding_the_object__this_.f0" href="#boost_localfunction.tutorial.binding_the_object__this_.f0" class="para">13</a>] </sup>
+ <span class="bold"><strong>Rationale.</strong></span> The special name <code class="computeroutput"><span class="identifier">this_</span></code> was chosen following <a href="http://lists.boost.org/Archives/boost/2011/04/179729.php" target="_top">Boost
+ practise</a> to postfix with an underscore identifiers that are named
+ after keywords (the C++ keyword <code class="computeroutput"><span class="keyword">this</span></code>
+ in this case). The special symbol <code class="computeroutput"><span class="identifier">this_</span></code>
+ is needed because <code class="computeroutput"><span class="keyword">this</span></code> is
+ a reserved C++ keyword so it cannot be used as the name of the internal
+ parameter that passes the bound object to the local function body. It would
+ have been possible to use <code class="computeroutput"><span class="keyword">this</span></code>
+ (instead of <code class="computeroutput"><span class="identifier">this_</span></code>) within
+ the local function body either at the expenses of copying the bound object
+ (which would introduce run-time overhead and also the stringent requirement
+ that the bound object must have a deep copy constructor) or by relying
+ on an <a href="http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/d3a86f27277f713b" target="_top">undefined
+ behaviour of <code class="computeroutput"><span class="keyword">static_cast</span></code></a>
+ (which might not work on all platforms at the cost of portability).
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.tutorial.binding_the_object__this_.f1" href="#boost_localfunction.tutorial.binding_the_object__this_.f1" class="para">14</a>] </sup>
+ <span class="bold"><strong>Rationale.</strong></span> The local function body cannot
+ be a static member function of the local functor object in order to support
+ recursion (because the local function name is specified by the <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code>
+ macro only after the body so it must be made available via a functor
+ data member named after the local function and local classes cannot have
+ static data members in C++) and nesting (because the argument binding
+ variable must be declared as a data member so it is visible in a local
+ function nested within the body member function) -- see the <a class="link" href="implementation.html" title="Annex: Implementation">Implementation</a>
+ section. Therefore, from within the local function body the variable
+ <code class="computeroutput"><span class="keyword">this</span></code> is visible but it refers
+ to the local functor and not to the bound object.
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.tutorial.binding_the_object__this_.f2" href="#boost_localfunction.tutorial.binding_the_object__this_.f2" class="para">15</a>] </sup>
+ <span class="bold"><strong>Rationale.</strong></span> This is possible because of
+ the fix to C++ <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#45" target="_top">defect
+ 45</a> that made inner and local types able to access all outer class
+ members regardless of their access level.
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.tutorial.templates.f0" href="#boost_localfunction.tutorial.templates.f0" class="para">16</a>] </sup>
+ <span class="bold"><strong>Rationale.</strong></span> Within templates, this library
+ needs to use <code class="computeroutput"><span class="keyword">typename</span></code> to explicitly
+ indicate that some expressions evaluate to a type. Because <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/standards" target="_top">C++03</a>
+ does not allow to use <code class="computeroutput"><span class="keyword">typename</span></code>
+ outside templates, the special <code class="computeroutput"><span class="special">...</span><span class="identifier">_TPL</span></code> macros are used to indicate that
+ the enclosing scope is a template so this library can safely use <code class="computeroutput"><span class="keyword">typename</span></code> to resolve expression type ambiguities.
+ <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a> and
+ other compilers might compile local functions within templates even when
+ the <code class="computeroutput"><span class="special">...</span><span class="identifier">_TPL</span></code>
+ macros are not used. However, it is recommended to always use the <code class="computeroutput"><span class="special">...</span><span class="identifier">_TPL</span></code>
+ macros within templates to maximize portability.
+ </p></div>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2009-2012 Lorenzo
+ Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="getting_started.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="advanced_topics.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/libs/local_function/doc/html/index.html b/libs/local_function/doc/html/index.html
new file mode 100644
index 000000000..c33c28fd5
--- /dev/null
+++ b/libs/local_function/doc/html/index.html
@@ -0,0 +1,235 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0</title>
+<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="next" href="boost_localfunction/getting_started.html" title="Getting Started">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
+<td align="center"><a href="../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav"><a accesskey="n" href="boost_localfunction/getting_started.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div>
+<div class="chapter">
+<div class="titlepage"><div>
+<div><h2 class="title">
+<a name="boost_localfunction"></a>Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0</h2></div>
+<div><div class="author"><h3 class="author">
+<span class="firstname">Lorenzo</span> <span class="surname">Caminiti <code class="email">&lt;<a class="email" href="mailto:lorcaminiti@gmail.com">lorcaminiti@gmail.com</a>&gt;</code></span>
+</h3></div></div>
+<div><p class="copyright">Copyright &#169; 2009-2012 Lorenzo
+ Caminiti</p></div>
+<div><div class="legalnotice">
+<a name="boost_localfunction.legal"></a><p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
+ </p>
+</div></div>
+</div></div>
+<div class="toc">
+<p><b>Table of Contents</b></p>
+<dl>
+<dt><span class="section"><a href="index.html#boost_localfunction.introduction">Introduction</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/getting_started.html">Getting Started</a></span></dt>
+<dd><dl>
+<dt><span class="section"><a href="boost_localfunction/getting_started.html#boost_localfunction.getting_started.this_documentation">This
+ Documentation</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/getting_started.html#boost_localfunction.getting_started.compilers_and_platforms">Compilers
+ and Platforms</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/getting_started.html#boost_localfunction.getting_started.installation">Installation</a></span></dt>
+</dl></dd>
+<dt><span class="section"><a href="boost_localfunction/tutorial.html">Tutorial</a></span></dt>
+<dd><dl>
+<dt><span class="section"><a href="boost_localfunction/tutorial.html#boost_localfunction.tutorial.local_functions">Local Functions</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/tutorial.html#boost_localfunction.tutorial.Binding">Binding Variables</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/tutorial.html#boost_localfunction.tutorial.binding_the_object__this_">Binding
+ the Object <code class="computeroutput"><span class="keyword">this</span></code></a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/tutorial.html#boost_localfunction.tutorial.templates">Templates</a></span></dt>
+</dl></dd>
+<dt><span class="section"><a href="boost_localfunction/advanced_topics.html">Advanced Topics</a></span></dt>
+<dd><dl>
+<dt><span class="section"><a href="boost_localfunction/advanced_topics.html#boost_localfunction.advanced_topics.default_parameters">Default
+ Parameters</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/advanced_topics.html#boost_localfunction.advanced_topics.commas_and_symbols_in_macros">Commas
+ and Symbols in Macros</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/advanced_topics.html#boost_localfunction.advanced_topics.assignments_and_returns">Assignments
+ and Returns</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/advanced_topics.html#boost_localfunction.advanced_topics.nesting">Nesting</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/advanced_topics.html#boost_localfunction.advanced_topics.accessing_types__concepts__etc_">Accessing
+ Types (concepts, etc)</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/advanced_topics.html#boost_localfunction.advanced_topics.specifying_types__no_boost_typeof_">Specifying
+ Types (no Boost.Typeof)</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/advanced_topics.html#boost_localfunction.advanced_topics.inlining">Inlining</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/advanced_topics.html#boost_localfunction.advanced_topics.recursion">Recursion</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/advanced_topics.html#boost_localfunction.advanced_topics.overloading">Overloading</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/advanced_topics.html#boost_localfunction.advanced_topics.exception_specifications">Exception
+ Specifications</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/advanced_topics.html#boost_localfunction.advanced_topics.storage_classifiers">Storage
+ Classifiers</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/advanced_topics.html#boost_localfunction.advanced_topics.same_line_expansions">Same
+ Line Expansions</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/advanced_topics.html#boost_localfunction.advanced_topics.limitations__operators__etc_">Limitations
+ (operators, etc)</a></span></dt>
+</dl></dd>
+<dt><span class="section"><a href="boost_localfunction/examples.html">Examples</a></span></dt>
+<dd><dl>
+<dt><span class="section"><a href="boost_localfunction/examples.html#boost_localfunction.examples.gcc_lambdas__without_c__11_">GCC
+ Lambdas (without C++11)</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/examples.html#boost_localfunction.examples.constant_blocks">Constant
+ Blocks</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/examples.html#boost_localfunction.examples.scope_exits">Scope Exits</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/examples.html#boost_localfunction.examples.boost_phoenix_functions">Boost.Phoenix
+ Functions</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/examples.html#boost_localfunction.examples.closures">Closures</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/examples.html#boost_localfunction.examples.gcc_nested_functions">GCC
+ Nested Functions</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/examples.html#boost_localfunction.examples.n_papers">N-Papers</a></span></dt>
+</dl></dd>
+<dt><span class="section"><a href="boost_localfunction/alternatives.html">Annex: Alternatives</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/no_variadic_macros.html">Annex: No Variadic
+ Macros</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/implementation.html">Annex: Implementation</a></span></dt>
+<dt><span class="section"><a href="reference.html">Reference</a></span></dt>
+<dd><dl>
+<dt><span class="section"><a href="reference.html#header.boost.local_function_hpp">Header &lt;boost/local_function.hpp&gt;</a></span></dt>
+<dt><span class="section"><a href="reference.html#header.boost.local_function.config_hpp">Header &lt;boost/local_function/config.hpp&gt;</a></span></dt>
+</dl></dd>
+<dt><span class="section"><a href="boost_localfunction/release_notes.html">Release Notes</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/bibliography.html">Bibliography</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/acknowledgments.html">Acknowledgments</a></span></dt>
+</dl>
+</div>
+<p>
+ This library allows to program functions locally, within other functions, and
+ directly within the scope where they are needed.
+ </p>
+<div class="section boost_localfunction_introduction">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="boost_localfunction.introduction"></a><a class="link" href="index.html#boost_localfunction.introduction" title="Introduction">Introduction</a>
+</h2></div></div></div>
+<p>
+ <span class="emphasis"><em>Local functions</em></span> (a.k.a., <a href="http://en.wikipedia.org/wiki/Nested_function" target="_top"><span class="emphasis"><em>nested
+ functions</em></span></a>) are a form of <span class="emphasis"><em>information hiding</em></span>
+ and they are useful for dividing procedural tasks into subtasks which are only
+ meaningful locally, avoiding cluttering other parts of the program with functions,
+ variables, etc unrelated to those parts. Therefore, local functions complement
+ other structuring possibilities such as namespaces and classes. Local functions
+ are a feature of many programming languages, notably <a href="http://en.wikipedia.org/wiki/Nested_function#An_example" target="_top">Pascal</a>
+ and <a href="http://en.wikipedia.org/wiki/Nesting_(computing)#In_programming" target="_top">Ada</a>,
+ yet lacking from <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/standards" target="_top">C++03</a>
+ (see also <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2511.html" target="_top">[N2511]</a>).
+ </p>
+<p>
+ Using <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a>, it is possible to implement local functions by naming
+ lambda functions assigning them to local variables. For example (see also
+ <a href="../../example/add_cxx11_lambda.cpp" target="_top"><code class="literal">add_cxx11_lambda.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><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="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">auto</span> <span class="identifier">add</span> <span class="special">=</span> <span class="special">[</span><span class="identifier">factor</span><span class="special">,</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="comment">// C++11 only.</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">add</span><span class="special">(</span><span class="number">1</span><span class="special">);</span> <span class="comment">// Call the lambda.</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_TEST</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="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span><span class="special">();</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ This library allows to program local functions portably between <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/standards" target="_top">C++03</a>
+ and <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a> (and
+ with performances comparable to lambda functions on <a href="http://www.open-std.org/JTC1/SC22/WG21/" target="_top">C++11</a>
+ compilers). For example (see also <a href="../../test/add.cpp" target="_top"><code class="literal">add.cpp</code></a>):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><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="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_TEST</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="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span><span class="special">();</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ This library supports the following features for local functions:
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+ Local functions can capture, or better <a href="http://en.wikipedia.org/wiki/Name_binding" target="_top"><span class="emphasis"><em>bind</em></span></a>,
+ any of the variables from the enclosing scope (a function together with
+ its captured variables is also called a <a href="http://en.wikipedia.org/wiki/Closure_(computer_science)" target="_top"><span class="emphasis"><em>closure</em></span></a>).
+ </li>
+<li class="listitem">
+ The local function body is programmed using the usual C++ statement syntax
+ (as a consequence, compiler errors and debugging retain their usual meaning
+ and format).
+ </li>
+<li class="listitem">
+ Local functions can be passed as template parameters so they can be conveniently
+ used with STL algorithms and other templates. <sup>[<a name="boost_localfunction.introduction.f0" href="#ftn.boost_localfunction.introduction.f0" class="footnote">1</a>]</sup>
+ </li>
+<li class="listitem">
+ However, local functions must be specified within a declarative context
+ (e.g., at a point in the code where local variables can be declared) thus
+ they cannot be specified within expressions. <sup>[<a name="boost_localfunction.introduction.f1" href="#ftn.boost_localfunction.introduction.f1" class="footnote">2</a>]</sup>
+ </li>
+</ul></div>
+<p>
+ See the <a class="link" href="boost_localfunction/alternatives.html" title="Annex: Alternatives">Alternatives</a>
+ section for a comparison between this library, <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a>, <a href="http://www.boost.org/libs/phoenix" target="_top">Boost.Phoenix</a>,
+ and other C++ techniques that implement features related to local functions.
+ </p>
+</div>
+<div class="footnotes">
+<br><hr width="100" align="left">
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.introduction.f0" href="#boost_localfunction.introduction.f0" class="para">1</a>] </sup>
+ This is a strength with respect to <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/standards" target="_top">C++03</a>
+ functors implemented using local classes which cannot be passed as template
+ parameters (see <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm" target="_top">[N2657]</a>
+ and the <a class="link" href="boost_localfunction/alternatives.html" title="Annex: Alternatives">Alternatives</a>
+ section).
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.introduction.f1" href="#boost_localfunction.introduction.f1" class="para">2</a>] </sup>
+ This is a weakness with respect to <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a> which can instead be specified also within expressions
+ (see the <a class="link" href="boost_localfunction/alternatives.html" title="Annex: Alternatives">Alternatives</a>
+ section).
+ </p></div>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"><p><small>Last revised: April 28, 2012 at 02:07:02 GMT</small></p></td>
+<td align="right"><div class="copyright-footer"></div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav"><a accesskey="n" href="boost_localfunction/getting_started.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div>
+</body>
+</html>
diff --git a/libs/local_function/doc/html/reference.html b/libs/local_function/doc/html/reference.html
new file mode 100644
index 000000000..a0b8634a7
--- /dev/null
+++ b/libs/local_function/doc/html/reference.html
@@ -0,0 +1,71 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Reference</title>
+<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="up" href="index.html" title="Chapter&#160;1.&#160;Boost.LocalFunction 1.0.0">
+<link rel="prev" href="boost_localfunction/implementation.html" title="Annex: Implementation">
+<link rel="next" href="BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
+<td align="center"><a href="../../../../index.html">Home</a></td>
+<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
+<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
+<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
+<td align="center"><a href="../../../../more/index.htm">More</a></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="boost_localfunction/implementation.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="section reference">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="reference"></a>Reference</h2></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"><a href="reference.html#header.boost.local_function_hpp">Header &lt;boost/local_function.hpp&gt;</a></span></dt>
+<dt><span class="section"><a href="reference.html#header.boost.local_function.config_hpp">Header &lt;boost/local_function/config.hpp&gt;</a></span></dt>
+</dl></div>
+<div class="section header_boost_local_function_hpp">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="header.boost.local_function_hpp"></a>Header &lt;<a href="../../../../boost/local_function.hpp" target="_top">boost/local_function.hpp</a>&gt;</h3></div></div></div>
+<p>Local functions allow to program functions locally, within other functions, and directly within the scope where they are needed. </p>
+<pre class="synopsis">
+
+<a class="link" href="BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a>(declarations)
+<a class="link" href="BOOST_LOCAL_FUNCTION_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_TPL">BOOST_LOCAL_FUNCTION_TPL</a>(declarations)
+<a class="link" href="BOOST_LOCAL_FUNCTION_ID.html" title="Macro BOOST_LOCAL_FUNCTION_ID">BOOST_LOCAL_FUNCTION_ID</a>(id, declarations)
+<a class="link" href="BOOST_LOCAL_FUNCTION_ID_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_ID_TPL">BOOST_LOCAL_FUNCTION_ID_TPL</a>(id, declarations)
+<a class="link" href="BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a>(qualified_name)
+<a class="link" href="BOOST_LOCAL_FUNCTION_NAME_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_NAME_TPL">BOOST_LOCAL_FUNCTION_NAME_TPL</a>(name)
+<a class="link" href="BOOST_LOCAL_FUNCTION_TYPEOF.html" title="Macro BOOST_LOCAL_FUNCTION_TYPEOF">BOOST_LOCAL_FUNCTION_TYPEOF</a>(bound_variable_name)</pre>
+</div>
+<div class="section header_boost_local_function_config_hpp">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="header.boost.local_function.config_hpp"></a>Header &lt;<a href="../../../../boost/local_function/config.hpp" target="_top">boost/local_function/config.hpp</a>&gt;</h3></div></div></div>
+<p>Configuration macros allow to change the behaviour of this library at compile-time. </p>
+<pre class="synopsis">
+
+<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>
+<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>
+<a class="link" href="BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS">BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS</a></pre>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright &#169; 2009-2012 Lorenzo
+ Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="boost_localfunction/implementation.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
diff --git a/libs/local_function/doc/implementation.qbk b/libs/local_function/doc/implementation.qbk
new file mode 100644
index 000000000..e85df5eac
--- /dev/null
+++ b/libs/local_function/doc/implementation.qbk
@@ -0,0 +1,50 @@
+
+[/ Copyright (C) 2009-2012 Lorenzo Caminiti ]
+[/ Distributed under the Boost Software License, Version 1.0 ]
+[/ (see accompanying file LICENSE_1_0.txt or a copy at ]
+[/ http://www.boost.org/LICENSE_1_0.txt) ]
+[/ Home at http://www.boost.org/libs/local_function ]
+
+[section:implementation Annex: Implementation]
+
+This section gives an overview of the key programming techniques used to implement this library.
+
+[note
+The code listed here can be used by curious readers and library maintainers as a reference in trying to understand the library source code.
+There is absolutely no guarantee that the library implementation uses the exact code listed here.
+]
+
+[heading Local Classes as Template Parameters]
+
+This library uses a local class to implement the local function object.
+However, in __CXX03__ local classes (and therefore the local function objects they implement) cannot be passed as template parameters (e.g., to the `std::for_each` algorithm), this is instead possible in __CXX11__, MSVC, and some other compilers (see __N2657__ and __Boost_Config__'s `BOOST_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS`).
+To work around this limitation, this library investigated the following two "tricks" (both tricks can be extended to support function default parameters):
+
+# The /casting functor trick/ uses a non-local functor that calls a static member function of the local class via a function pointer.
+The static member function then calls the correct local function body after type casting the object from a `void*` pointer (local classes can always be used for type casting via `static_cast` or similar).
+
+# The /virtual functor trick/ derives the local functor class from a non-local base class.
+The correct overridden implementation of the virtual `operator()` is then called via dynamic binding.
+
+For example (see also [@../../example/impl_tparam_tricks.cpp =impl_tparam_tricks.cpp=]):
+
+[impl_tparam_tricks]
+
+The casting functor trick measured slightly better run-time performances than the virtual functor trick so the current implementation of this library uses the casting functor trick (probably because in addition to the indirect function call, the virtual functor trick also requires accessing the [@http://en.wikipedia.org/wiki/Virtual_method_table virtual function table]).
+However, neither one of the two tricks was observed to allow for compiler optimizations that inline the local function calls (because they rely on one indirect function call via either a function pointer or a virtual function respectively).
+Therefore, on compilers that accept local classes as template parameters (MSVC, __CXX11__, etc, see __N2657__ and __Boost_Config__'s `BOOST_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS`), this library automatically generates code that passes the local class type directly as template parameter without using neither one of these two tricks in order to take full advantage of compiler optimizations that inline the local function calls.
+
+[heading Parsing Macros]
+
+This library macros can parse the list of specified parameters and detect if any of the bound variable names matches the token `this_` (to generate special code to bind the object in scope), or if the variable is bound by `const` (to generate special code to bind by constant), etc.
+The parameter tokens are inspected using preprocessor meta-programming and specifically using the macros defined by the files in the =boost/local_function/detail/preprocessor/keyword/= directory.
+[footnote
+This technique is at the core of even more complex preprocessor parsing macros like the ones that parse the __Contractpp__ syntax.
+]
+
+For example, the following code defines a macro that allows the preprocessor to detect if a set of space-separated tokens ends with `this_` or not (see also [@../../example/impl_pp_keyword.cpp =impl_pp_keyword.cpp=]):
+
+[impl_pp_keyword]
+
+[endsect]
+
diff --git a/libs/local_function/doc/introduction.qbk b/libs/local_function/doc/introduction.qbk
new file mode 100644
index 000000000..a9d145694
--- /dev/null
+++ b/libs/local_function/doc/introduction.qbk
@@ -0,0 +1,40 @@
+
+[/ Copyright (C) 2009-2012 Lorenzo Caminiti ]
+[/ Distributed under the Boost Software License, Version 1.0 ]
+[/ (see accompanying file LICENSE_1_0.txt or a copy at ]
+[/ http://www.boost.org/LICENSE_1_0.txt) ]
+[/ Home at http://www.boost.org/libs/local_function ]
+
+[section Introduction]
+
+/Local functions/ (a.k.a., [@http://en.wikipedia.org/wiki/Nested_function /nested functions/]) are a form of /information hiding/ and they are useful for dividing procedural tasks into subtasks which are only meaningful locally, avoiding cluttering other parts of the program with functions, variables, etc unrelated to those parts.
+Therefore, local functions complement other structuring possibilities such as namespaces and classes.
+Local functions are a feature of many programming languages, notably [@http://en.wikipedia.org/wiki/Nested_function#An_example Pascal] and [@http://en.wikipedia.org/wiki/Nesting_(computing)#In_programming Ada], yet lacking from __CXX03__ (see also __N2511__).
+
+Using __CXX11_lambda_functions__, it is possible to implement local functions by naming lambda functions assigning them to local variables.
+For example (see also [@../../example/add_cxx11_lambda.cpp =add_cxx11_lambda.cpp=]):
+
+[add_cxx11_lambda]
+
+This library allows to program local functions portably between __CXX03__ and __CXX11__ (and with performances comparable to lambda functions on __CXX11__ compilers).
+For example (see also [@../../test/add.cpp =add.cpp=]):
+
+[add]
+
+This library supports the following features for local functions:
+
+* Local functions can capture, or better [@http://en.wikipedia.org/wiki/Name_binding /bind/], any of the variables from the enclosing scope (a function together with its captured variables is also called a [@http://en.wikipedia.org/wiki/Closure_(computer_science) /closure/]).
+* The local function body is programmed using the usual C++ statement syntax (as a consequence, compiler errors and debugging retain their usual meaning and format).
+* Local functions can be passed as template parameters so they can be conveniently used with STL algorithms and other templates.
+[footnote
+This is a strength with respect to __CXX03__ functors implemented using local classes which cannot be passed as template parameters (see __N2657__ and the __Alternatives__ section).
+]
+* However, local functions must be specified within a declarative context (e.g., at a point in the code where local variables can be declared) thus they cannot be specified within expressions.
+[footnote
+This is a weakness with respect to __CXX11_lambda_functions__ which can instead be specified also within expressions (see the __Alternatives__ section).
+]
+
+See the __Alternatives__ section for a comparison between this library, __CXX11_lambda_functions__, __Boost_Phoenix__, and other C++ techniques that implement features related to local functions.
+
+[endsect]
+
diff --git a/libs/local_function/doc/local_function.qbk b/libs/local_function/doc/local_function.qbk
new file mode 100644
index 000000000..42f92b647
--- /dev/null
+++ b/libs/local_function/doc/local_function.qbk
@@ -0,0 +1,126 @@
+
+[/ Copyright (C) 2009-2012 Lorenzo Caminiti ]
+[/ Distributed under the Boost Software License, Version 1.0 ]
+[/ (see accompanying file LICENSE_1_0.txt or a copy at ]
+[/ http://www.boost.org/LICENSE_1_0.txt) ]
+[/ Home at http://www.boost.org/libs/local_function ]
+
+[library Boost.LocalFunction
+ [quickbook 1.5]
+ [version 1.0.0]
+ [copyright 2009-2012 Lorenzo Caminiti]
+ [purpose declare functions at local scope]
+ [license
+ Distributed under the Boost Software License, Version 1.0
+ (see accompanying file LICENSE_1_0.txt or a copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+ ]
+ [authors [Caminiti <email>lorcaminiti@gmail.com</email>, Lorenzo]]
+ [category Function Objects and Higher-Order Programming]
+]
+
+[def __CXX03__ [@http://www.open-std.org/JTC1/SC22/WG21/docs/standards C++03]]
+[def __CXX11__ [@http://www.open-std.org/JTC1/SC22/WG21/ C++11]]
+[def __C99__ [@http://www.open-std.org/jtc1/sc22/wg14/www/projects#9899 C99]]
+[def __Boost__ [@http://www.boost.org Boost]]
+[def __Boost_LocalFunction__ [@http://www.boost.org/libs/local_function Boost.LocalFunction]]
+[def __Boost_ScopeExit__ [@http://www.boost.org/libs/scope_exit Boost.ScopeExit]]
+[def __Boost_Test__ [@http://www.boost.org/libs/test Boost.Test]]
+[def __Boost_Lambda__ [@http://www.boost.org/libs/lambda Boost.Lambda]]
+[def __Boost_Phoenix__ [@http://www.boost.org/libs/phoenix Boost.Phoenix]]
+[def __Boost_Preprocessor__ [@http://www.boost.org/libs/preprocessor Boost.Preprocessor]]
+[def __Boost_MPL__ [@http://www.boost.org/libs/mpl Boost.MPL]]
+[def __Boost_ConceptCheck__ [@http://www.boost.org/libs/concept_check Boost.ConceptCheck]]
+[def __Boost_Parameter__ [@http://www.boost.org/libs/parameter Boost.Paramater]]
+[def __Boost_Typeof__ [@http://www.boost.org/libs/typeof Boost.Typeof]]
+[def __Boost_Function__ [@http://www.boost.org/libs/function Boost.Function]]
+[def __Boost_Functional_OverloadedFunction__ [@http://www.boost.org/libs/functional/overloaded_function Boost.Functional/OverloadedFunction]]
+[def __Boost_TypeTraits__ [@http://www.boost.org/libs/type_traits Boost.TypeTraits]]
+[def __Boost_Utility_IdentityType__ [@http://www.boost.org/libs/utility/identity_type Boost.Utility/IdentityType]]
+[def __Boost_Chrono__ [@http://www.boost.org/libs/chrono Boost.Chrono]]
+[def __Boost_Config__ [@http://www.boost.org/libs/chrono Boost.Config]]
+[def __CXX11_lambda_functions__ [@http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions C++11 lambda functions]]
+[def __LISP__ [@http://en.wikipedia.org/wiki/Lisp_(programming_language) LISP]]
+[def __Contractpp__ [@http://sourceforge.net/projects/contractpp Contract++]]
+[def __D_Programming_Language__ [@http://d.digitalmars.com D Programming Language]]
+[def __expression_template__ [@http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Expression-template expression template]]
+[def __N1613__ [@http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2004/n1613.pdf \[N1613\]]]
+[def __N2511__ [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2511.html \[N2511\]]]
+[def __N2529__ [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2529.pdf \[N2529\]]]
+[def __N2550__ [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2550.pdf \[N2550\]]]
+[def __N2657__ [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm \[N2657\]]]
+
+[def __Introduction__ [link boost_localfunction.introduction Introduction]]
+[def __Getting_Started__ [link boost_localfunction.getting_started Getting Started]]
+[def __Tutorial__ [link boost_localfunction.tutorial Tutorial]]
+[def __Advanced_Topics__ [link boost_localfunction.advanced_topics Advanced Topics]]
+[def __Examples__ [link boost_localfunction.examples Examples]]
+[def __Reference__ [@reference.html Reference]]
+[def __Alternatives__ [link boost_localfunction.alternatives Alternatives]]
+[def __No_Variadic_Macros__ [link boost_localfunction.no_variadic_macros No Variadic Macros]]
+[def __Implementation__ [link boost_localfunction.implementation Implementation]]
+[def __Release_Notes__ [link boost_localfunction.release_notes Release Notes]]
+[def __Bibliography__ [link boost_localfunction.bibliography Bibliography]]
+[def __Acknowledgments__ [link boost_localfunction.acknowledgments Acknowledgments]]
+
+[import ../test/add.cpp]
+[import ../test/add_seq.cpp]
+[import ../test/add_params_only.cpp]
+[import ../test/ten_void.cpp]
+[import ../test/add_this.cpp]
+[import ../test/add_template.cpp]
+[import ../test/add_default.cpp]
+[import ../test/add_with_default.cpp]
+[import ../test/macro_commas.cpp]
+[import ../test/return_assign.cpp]
+[import ../test/transform.cpp]
+[import ../test/typeof.cpp]
+[import ../test/typeof_template.cpp]
+[import ../test/add_typed.cpp]
+[import ../test/add_inline.cpp]
+[import ../test/nesting.cpp]
+[import ../test/factorial.cpp]
+[import ../test/overload.cpp]
+[import ../test/add_except.cpp]
+[import ../test/add_classifiers.cpp]
+[import ../test/operator_error.cpp]
+[import ../test/goto.cpp]
+[import ../test/goto_error.cpp]
+[import ../test/same_line.cpp]
+
+[import ../example/add_cxx11_lambda.cpp]
+[import ../example/gcc_lambda.hpp]
+[import ../example/gcc_lambda.cpp]
+[import ../example/gcc_cxx11_lambda.cpp]
+[import ../example/const_block.hpp]
+[import ../example/const_block_error.cpp]
+[import ../example/const_block_error_cxx11_lambda.cpp]
+[import ../example/scope_exit.hpp]
+[import ../example/scope_exit.cpp]
+[import ../example/phoenix_factorial_local.cpp]
+[import ../example/phoenix_factorial.cpp]
+[import ../example/noncopyable_cxx11_lambda_error.cpp]
+[import ../example/noncopyable_local_function.cpp]
+[import ../example/expensive_copy_cxx11_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]
+
+This library allows to program functions locally, within other functions, and directly within the scope where they are needed.
+
+[include introduction.qbk]
+[include getting_started.qbk]
+[include tutorial.qbk]
+[include advanced_topics.qbk]
+[include examples.qbk]
+[include alternatives.qbk]
+[include no_variadic_macros.qbk]
+[include implementation.qbk]
+[xinclude reference.xml]
+[include release_notes.qbk]
+[include bibliography.qbk]
+[include acknowledgements.qbk]
+
diff --git a/libs/local_function/doc/no_variadic_macros.qbk b/libs/local_function/doc/no_variadic_macros.qbk
new file mode 100644
index 000000000..35f3548ff
--- /dev/null
+++ b/libs/local_function/doc/no_variadic_macros.qbk
@@ -0,0 +1,68 @@
+
+[/ Copyright (C) 2009-2012 Lorenzo Caminiti ]
+[/ Distributed under the Boost Software License, Version 1.0 ]
+[/ (see accompanying file LICENSE_1_0.txt or a copy at ]
+[/ http://www.boost.org/LICENSE_1_0.txt) ]
+[/ Home at http://www.boost.org/libs/local_function ]
+
+[section:no_variadic_macros Annex: No Variadic Macros]
+
+This section illustrates an alternative syntax for compilers without variadic macro support.
+
+[heading Sequence Syntax]
+
+Most modern compilers support [@http://en.wikipedia.org/wiki/Variadic_macro variaid macros] (notably, these include GCC, MSVC, and all __CXX11__ compilers).
+However, in the rare case that programmers need to use this library on a compiler without variadic macros, this library also allows to specify its macro parameters using a __Boost_Preprocessor__ sequence where tokens are separated by round parenthesis `()`:
+
+ (token1) (token2) ... // All compilers.
+
+Instead of the comma-separated list that we have seen so far which requires variadic macros:
+
+ token1, token2, ... // Only compilers with varidic macros.
+
+For example, the following syntax is accepted on all compilers with and without variadic macros (see also [@../../test/add_seq.cpp =add_seq.cpp=]):
+
+[add_seq]
+
+However, on compilers with variadic macros the comma-separated syntax we have seen so far is preferred because more readable (see also [@../../test/add.cpp =add.cpp=]):
+
+[add]
+
+Note that the same macros accept both syntaxes on compilers with variadic macros and only the sequence syntax on compilers without variadic macros.
+Finally, an empty local function parameter list is always specified using `void` on compilers with and without variadic macros:
+
+[ten_void]
+
+[heading Examples]
+
+For reference, the following is a list of most of the examples presented in this documentation reprogrammed using the sequence syntax instead of the comma-separated syntax (in alphabetic order):
+
+[table
+ [ [Files] ]
+ [ [[@../../test/add_classifiers_seq.cpp =add_classifiers_seq.cpp=]] ]
+ [ [[@../../test/add_default_seq.cpp =add_default_seq.cpp=]] ]
+ [ [[@../../test/add_except_seq.cpp =add_except_seq.cpp=]] ]
+ [ [[@../../test/add_inline_seq.cpp =add_inline_seq.cpp=]] ]
+ [ [[@../../test/add_params_only_seq.cpp =add_params_only_seq.cpp=]] ]
+ [ [[@../../test/add_template_seq.cpp =add_template_seq.cpp=]] ]
+ [ [[@../../test/add_this_seq.cpp =add_this_seq.cpp=]] ]
+ [ [[@../../test/add_typed_seq.cpp =add_typed_seq.cpp=]] ]
+ [ [[@../../test/add_with_default_seq.cpp =add_with_default_seq.cpp=]] ]
+ [ [[@../../test/all_decl_seq.cpp =all_decl_seq.cpp=]] ]
+ [ [[@../../test/factorial_seq.cpp =factorial_seq.cpp=]] ]
+ [ [[@../../test/macro_commas_seq.cpp =macro_commas_seq.cpp=]] ]
+ [ [[@../../test/nesting_seq.cpp =nesting_seq.cpp=]] ]
+ [ [[@../../test/overload_seq.cpp =overload_seq.cpp=]] ]
+ [ [[@../../test/return_assign_seq.cpp =return_assign_seq.cpp=]] ]
+ [ [[@../../test/return_derivative_seq.cpp =return_derivative_seq.cpp=]] ]
+ [ [[@../../test/return_inc_seq.cpp =return_inc_seq.cpp=]] ]
+ [ [[@../../test/return_setget_seq.cpp =return_setget_seq.cpp=]] ]
+ [ [[@../../test/return_this_seq.cpp =return_this_seq.cpp=]] ]
+ [ [[@../../test/same_line_seq.cpp =same_line_seq.cpp=]] ]
+ [ [[@../../test/transform_seq.cpp =transform_seq.cpp=]] ]
+ [ [[@../../test/typeof_seq.cpp =typeof_seq.cpp=]] ]
+ [ [[@../../test/typeof_template_seq.cpp =typeof_template_seq.cpp=]] ]
+]
+
+[endsect]
+
diff --git a/libs/local_function/doc/release_notes.qbk b/libs/local_function/doc/release_notes.qbk
new file mode 100644
index 000000000..0fbf2097e
--- /dev/null
+++ b/libs/local_function/doc/release_notes.qbk
@@ -0,0 +1,54 @@
+
+[/ Copyright (C) 2009-2012 Lorenzo Caminiti ]
+[/ Distributed under the Boost Software License, Version 1.0 ]
+[/ (see accompanying file LICENSE_1_0.txt or a copy at ]
+[/ http://www.boost.org/LICENSE_1_0.txt) ]
+[/ Home at http://www.boost.org/libs/local_function ]
+
+[section Release Notes]
+
+This section lists the major changes between different library releases (in chronological order).
+
+[heading Version 1.0.0 (2012-04-12)]
+
+# Incorporated all comments from the [@http://lists.boost.org/boost-announce/2011/12/0340.php Boost review of this library].
+# Removed local blocks and local exits.
+# Renamed the library from Boost.Local to Boost.LocalFunction.
+# Using `this_` instead of `this` also in the local function declaration (not just the body).
+# Made changes that allow to return local functions (similar to closures).
+# Added GCC lambda and constant block examples.
+# Moved `overloaded_function` to Boost.Functional/OverloadedFunction.
+# Moved `BOOST_IDENTITY_TYPE` to Boost.Utility/IdentityType.
+# Completely removed use of Boost.Typeof when bound and result types are explicitly specified.
+# Added `..._ID` macros for multiple expansions on the same line.
+# Fixed compilation on Boost regression test platforms.
+
+[heading Version 0.2.0 (2011-05-14)]
+
+# Replaced parenthesized syntax with variadic and sequencing macro syntaxes.
+# Profiled library performances against other approaches.
+# Replaced virtual functor trick with casting functor trick (for smaller run-time).
+# Optimized library run-time (rearranging code and not using casting functor trick on compilers that accept local classes as template parameters).
+# Supported inline and recursive local functions.
+# Added type-of macro to expose bound types.
+# Allowed to explicitly specify bound types.
+# Removed using `boost::function` instead of exposing internal local functor as public API.
+# Added functor to overload local functions (and functors in general).
+# Implemented support for nesting local functions, blocks, and exits into one another.
+
+[heading Version 0.1.1 (2011-01-10)]
+
+# Uploaded library source into Boost SVN sandbox.
+# Fixed prev/next arrows and other minor layouts in documentation.
+# Added Release section to documentation.
+
+[heading Version 0.1.0 (2011-01-03)]
+
+# Shared with Boost for first round of comments.
+
+[heading Version 0.0.1 (2010-12-15)]
+
+# Completed development, examples, and documentation.
+
+[endsect]
+
diff --git a/libs/local_function/doc/tutorial.qbk b/libs/local_function/doc/tutorial.qbk
new file mode 100644
index 000000000..3313d58ef
--- /dev/null
+++ b/libs/local_function/doc/tutorial.qbk
@@ -0,0 +1,225 @@
+
+[/ Copyright (C) 2009-2012 Lorenzo Caminiti ]
+[/ Distributed under the Boost Software License, Version 1.0 ]
+[/ (see accompanying file LICENSE_1_0.txt or a copy at ]
+[/ http://www.boost.org/LICENSE_1_0.txt) ]
+[/ Home at http://www.boost.org/libs/local_function ]
+
+[section Tutorial]
+
+This section illustrates basic usage of this library.
+
+[section Local Functions]
+
+Local functions are defined using macros from the header file [headerref boost/local_function.hpp].
+The macros must be used from within a declarative context (this is a limitation with respect to __CXX11_lambda_functions__ which can instead be declared also within expressions):
+
+ #include <boost/local_function.hpp> // This library header.
+
+ ...
+ { // Some declarative context.
+ ...
+ ``/result-type/`` BOOST_LOCAL_FUNCTION(``/parameters/``) {
+ ``/body-code/``
+ } BOOST_LOCAL_FUNCTION_NAME(``/name/``)
+ ...
+ }
+
+The code expanded by the macros declares a function object (or [@http://en.wikipedia.org/wiki/Functor functor]) with the local function name specified by [macroref BOOST_LOCAL_FUNCTION_NAME].
+[footnote
+*Rationale.*
+The local function name must be passed to the macro [macroref BOOST_LOCAL_FUNCTION_NAME] ending the function definition so this macro can declare a local variable with the local function name to hold the local function object.
+Therefore the local function name cannot be specified within the [macroref BOOST_LOCAL_FUNCTION] and it must appear instead after the local function body (even if that differs from the usual C++ function declaration syntax).
+]
+The usual C++ scope visibility rules apply to local functions for which a local function is visible only within the enclosing scope in which it is declared.
+
+The local function result type is specified just before the [macroref BOOST_LOCAL_FUNCTION] macro.
+
+The local function body is specified using the usual C++ statement syntax in a code block `{ ... }` between the [macroref BOOST_LOCAL_FUNCTION] and [macroref BOOST_LOCAL_FUNCTION_NAME] macros.
+The body is specified outside any of the macros so eventual compiler error messages and related line numbers retain their usual meaning and format.
+[footnote
+*Rationale.*
+If the local function body were instead passed as a macro parameter, it would be expanded on a single line of code (because macros always expand as a single line of code).
+Therefore, eventual compiler error line numbers would all report the same value and would no longer be useful to pinpoint errors.
+]
+
+The local function parameters are passed to the [macroref BOOST_LOCAL_FUNCTION] macro as a comma-separated list of tokens (see the __No_Variadic_Macros__ section for compilers that do not support variadic macros):
+
+ BOOST_LOCAL_FUNCTION(``[^/parameter-type1 parameter-name1/]``,`` [^/parameter-type2 parameter-name2, .../]``)
+
+The maximum number of parameters that can be passed to a local function is controlled at compile-time by the configuration macro [macroref BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX].
+For example, let's program a local function named `add` that adds together two integers `x` and `y` (see also [@../../test/add_params_only.cpp =add_params_only.cpp=]):
+
+[add_params_only]
+
+If the local function has no parameter, it is possible to pass `void` to the [macroref BOOST_LOCAL_FUNCTION] macro (similarly to the C++ syntax that allows to use [^['result-type function-name]]`(void)` to declare a function with no parameter):
+[footnote
+*Rationale.*
+The __CXX03__ standard does not allow to pass empty parameters to a macro so the macro cannot be invoked as `BOOST_LOCAL_FUNCTION()`.
+On __C99__ compilers with properly implemented empty macro parameter support, it would be possible to allow `BOOST_LOCAL_FUNCTION()` but this is already not the case for MSVC so this syntax is never allowed to ensure better portability.
+]
+
+ BOOST_LOCAL_FUNCTION(void) // No parameter.
+
+For example, let's program a local function that always returns `10` (see also [@../../test/ten_void.cpp =ten_void.cpp=]):
+
+[ten_void]
+
+[endsect]
+
+[section:Binding Binding Variables]
+
+Variables in scope (local variables, enclosing function parameters, data members, etc) can be bound to a local function declaration.
+Only bound variables, static variables, global variables, functions, and enumerations from the enclosing scope are accessible from within the local function body.
+The types of bound variables are deduced automatically by this library using __Boost_Typeof__.
+[footnote
+*Rationale.*
+By binding a variable in scope, the local function declaration is specifying that such a variable should be accessible within the local function body regardless of its type.
+Semantically, this binding should be seen as an "extension" of the scope of the bound variable from the enclosing scope to the scope of the local function body.
+Therefore, contrary to the semantic of passing a function parameter, the semantic of binding a variable does not depend on the variable type but just on the variable name: "The variable in scope named /x/ should be accessible within the local function named /f/".
+For example, this reduces maintenance because if a bound variable type is changed, the local function declaration does not have to change.
+]
+
+This library introduces the new "keyword" `bind`
+[footnote
+Obviously, the token `bind` is not a keyword of the C++ language.
+This library parses the token `bind` during macro expansion using preprocessor meta-programming (see the __Implementation__ section).
+Therefore, `bind` can be considered a new "keyword" only at the preprocessor meta-programming level within the syntax defined by the macros of this library (thus it is referred to as a "keyword" only within quotes).
+]
+which is used in place of the parameter type to specify the name of a variable in scope to bind (therefore, `bind` cannot be used as a local function parameter type).
+A variable can be bound by value:
+
+ bind ``/variable-name/`` // Bind by value.
+
+Or by reference prefixing the variable name with `&`:
+
+ bind& ``/variable-name/`` // Bind by reference.
+
+Furthermore, the "keyword" `bind` can be prefixed by `const` to bind the variable by constant value:
+
+ const bind ``/variable-name/`` // Bind by constant value.
+
+Or by constant reference:
+
+ const bind& ``/variable-name/`` // Bind by constant value.
+
+Note that when `const` is used, it must always precede `bind`.
+[footnote
+*Rationale.*
+The library macros could have been implemented to accept both syntaxes `const bind ...` and `bind const ...` equivalently.
+However, handling both syntaxes would have complicated the macro implementation without adding any feature so only one syntax `const bind ...` is supported.
+]
+
+If a variable is bound by value, then a copy of the variable value is taken at the point of the local function declaration.
+If a variable is bound by reference instead, the variable will refer to the value it has at the point of the local function call.
+Furthermore, it is the programmers' responsibility to ensure that variables bound by reference survive the existence scope of the local function otherwise the bound references will be invalid when the local function is called resulting in undefined behaviour (in other words, the usual care in using C++ references must be taken for variables bound by reference).
+
+The type of a bound variable is automatically deduced using __Boost_Typeof__ and it is the exact same type used to declare such a variable in the enclosing scope with the following notes:
+
+* If a bound variable was declared constant in the enclosing scope, it will always be bound by constant value or constant reference even if `bind...` is used instead of `const bind...` .
+However, if a bound variable was not declared constant in the enclosing scope then it will not be bound as constant unless constant binding is forced using `const bind...`.
+(Note that binding by constant reference is not supported by __CXX11_lambda_functions__ but it is supported by this library.)
+[footnote
+An historical note: Constant binding of variables in scope was the main use case that originally motivated the authors in developing this library.
+The authors needed to locally create a chuck of code to assert some correctness conditions while these assertions were not supposed to modify any of the variables they were using (see the __Contractpp__ library).
+This was achieved by binding by constant reference `const bind&` the variables needed by the assertions and then by programming the local function body to check the assertions.
+This way if any of the assertions mistakenly changes a bound variable (for example confusing the operator `==` with `=`), the compiler correctly generates an error because the bound variable is of `const` type within the local function body (see also /constant blocks/ in the __Examples__ section).
+]
+* If a bound variable was declared as a reference in the enclosing scope, it will still be bound by value unless it is explicitly bound by reference using `bind&` or `const bind&`.
+[footnote
+*Rationale.*
+Variables originally declared as references are bound by value unless `[const] bind&` is used so that references can be bound by both value `[const] bind` and reference `[const] bind&` (this is the same binding semantic adopted by __Boost_ScopeExit__).
+However, variables originally declared as constants should never loose their `const` qualifier (to prevent their modification not just in the enclosing scope but also in the local scope) thus they are always bound by constant even if `bind[&]` is used instead of `const bind[&]`.
+]
+
+When a variable is bound by value (constant or not), its type must be [@http://www.boost.org/doc/libs/release/doc/html/CopyConstructible.html `CopyConstructible`] (i.e., its must provide a copy constructor).
+As with passing parameters to usual C++ functions, programmers might want to bind variables of complex types by (possibly constant) reference instead of by value to avoid expensive copy operations when these variables are bound to a local function.
+
+For example, let's program the local function `add` from the example in the __Introduction__ section.
+We bind the local variable `factor` by constant value (because its value should not be modified by the local function), the local variable `sum` by non-constant reference (because its value needs to be updated with the summation result), and program the body to perform the summation (see also [@../../test/add.cpp =add.cpp=]):
+
+[add]
+
+[endsect]
+
+[section Binding the Object `this`]
+
+It is also possible to bind the object `this` when it is in scope (e.g., from an enclosing non-static member function).
+This is done by using the special symbol `this_` (instead of `this`) as the name of the variable to bind in the local function declaration and also to access the object within the local function body.
+[footnote
+*Rationale.*
+The special name `this_` was chosen following [@http://lists.boost.org/Archives/boost/2011/04/179729.php Boost practise] to postfix with an underscore identifiers that are named after keywords (the C++ keyword `this` in this case).
+The special symbol `this_` is needed because `this` is a reserved C++ keyword so it cannot be used as the name of the internal parameter that passes the bound object to the local function body.
+It would have been possible to use `this` (instead of `this_`) within the local function body either at the expenses of copying the bound object (which would introduce run-time overhead and also the stringent requirement that the bound object must have a deep copy constructor) or by relying on an [@http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/d3a86f27277f713b undefined behaviour of `static_cast`] (which might not work on all platforms at the cost of portability).
+]
+
+[warning
+The library will generate a compile-time error if `this` is mistakenly used instead of `this_` to bind the object in the local function declaration.
+However, mistakenly using `this` instead of `this_` to access the object within the local function body will leads to undefined behaviour and it will not necessarily generate a compile-time error.
+[footnote
+*Rationale.*
+The local function body cannot be a static member function of the local functor object in order to support recursion (because the local function name is specified by the [macroref BOOST_LOCAL_FUNCTION_NAME] macro only after the body so it must be made available via a functor data member named after the local function and local classes cannot have static data members in C++) and nesting (because the argument binding variable must be declared as a data member so it is visible in a local function nested within the body member function) -- see the __Implementation__ section.
+Therefore, from within the local function body the variable `this` is visible but it refers to the local functor and not to the bound object.
+]
+Programmers are ultimately responsible to make sure that `this` is never used within a local function.
+]
+
+The object `this` can be bound by value:
+
+ bind this_ // Bind the object `this` by value.
+
+In this case the local function will be able to modify the object when the enclosing scope is not a constant member and it will not be able to modify the object when the enclosing scope is a constant member.
+Otherwise, the object `this` can be bound by constant value:
+
+ const bind this_ // Bind the object `this` by constant value.
+
+In this case the local function will never be able to modify the object (regardless of whether the enclosing scope is a constant member or not).
+
+Note that the object `this` can never be bound by reference because C++ does not allow to obtain a reference to `this` (the library will generate a compile-time error if programmers try to use `bind& this_` or `const bind& this_`).
+Note that `this` is a pointer so the pointed object is never copied even if `this` is bound by value (also it is not possible to directly bind `*this` because `*this` is an expression and not a variable name).
+
+For example, let's program a local function `add` similar to the one in the example from the __Introduction__ section but using a member function to illustrate how to bind the object `this` (see also [@../../test/add_this.cpp =add_this.cpp=]):
+
+[add_this]
+
+Note that the local function has access to all class members via the bound object `this_` regardless of their access level (`public`, `protected`, or `private`).
+[footnote
+*Rationale.*
+This is possible because of the fix to C++ [@http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#45 defect 45] that made inner and local types able to access all outer class members regardless of their access level.
+]
+Specifically, in the example above the local function updates the private data member `sum_`.
+
+[endsect]
+
+[section Templates]
+
+When local functions are programmed within templates, they need to be declared using the special macros [macroref BOOST_LOCAL_FUNCTION_TPL] and [macroref BOOST_LOCAL_FUNCTION_NAME_TPL]:
+[footnote
+*Rationale.*
+Within templates, this library needs to use `typename` to explicitly indicate that some expressions evaluate to a type.
+Because __CXX03__ does not allow to use `typename` outside templates, the special `..._TPL` macros are used to indicate that the enclosing scope is a template so this library can safely use `typename` to resolve expression type ambiguities.
+__CXX11__ and other compilers might compile local functions within templates even when the `..._TPL` macros are not used.
+However, it is recommended to always use the `..._TPL` macros within templates to maximize portability.
+]
+
+ #include <boost/local_function.hpp> // This library header.
+
+ ...
+ { // Some declarative context within a template.
+ ...
+ ``/result-type/`` BOOST_LOCAL_FUNCTION_TPL(``/parameters/``) {
+ ``/body-code/``
+ } BOOST_LOCAL_FUNCTION_NAME_TPL(``/name/``)
+ ...
+ }
+
+The [macroref BOOST_LOCAL_FUNCTION_TPL] and [macroref BOOST_LOCAL_FUNCTION_NAME_TPL] macros have the exact same syntax of the [macroref BOOST_LOCAL_FUNCTION] and [macroref BOOST_LOCAL_FUNCTION_NAME] macros that we have seen so far.
+
+For example, let's program a local function similar to the one from the __Introduction__ section but within a template (see also [@../../test/add_template.cpp =add_template.cpp=]):
+
+[add_template]
+
+[endsect]
+
+[endsect]
+
diff --git a/libs/local_function/example/Jamfile.v2 b/libs/local_function/example/Jamfile.v2
new file mode 100644
index 000000000..198027163
--- /dev/null
+++ b/libs/local_function/example/Jamfile.v2
@@ -0,0 +1,77 @@
+
+# Copyright (C) 2009-2012 Lorenzo Caminiti
+# Distributed under the Boost Software License, Version 1.0
+# (see accompanying file LICENSE_1_0.txt or a copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+# Home at http://www.boost.org/libs/local_function
+
+import testing ;
+
+# Sun does not automatically detect type-of emulation mode (force it).
+project : requirements <toolset>sun:<define>BOOST_TYPEOF_EMULATION ;
+
+run add_cxx11_lambda.cpp ;
+run add_global_functor.cpp ;
+run add_local_functor.cpp ;
+run add_phoenix.cpp ;
+
+run const_block.cpp ;
+compile-fail const_block_error.cpp : <variant>debug : ;
+run const_block_error.cpp : <variant>release : ;
+compile-fail const_block_error_cxx11_lambda.cpp ;
+
+run expensive_copy_cxx11_lambda.cpp ;
+run expensive_copy_local_function.cpp ;
+
+run gcc_access.cpp ;
+run gcc_lambda.cpp ;
+run gcc_cxx11_lambda.cpp ;
+run gcc_square.cpp ;
+run gcc_store.cpp ;
+
+run impl_pp_keyword.cpp ;
+run impl_tparam_tricks.cpp ;
+
+run n2529_this.cpp ;
+run n2550_find_if.cpp ;
+
+compile-fail noncopyable_cxx11_lambda_error.cpp ;
+run noncopyable_local_function.cpp ;
+
+run phoenix_factorial.cpp ;
+run phoenix_factorial_local.cpp ;
+
+# Only compile but do not run profiling programs (they take a long time to run).
+exe profile_global_functor : profile_global_functor.cpp
+ : <library>/boost/chrono//boost_chrono
+ <library>/boost/system//boost_system
+ <link>static
+ ;
+exe profile_cxx11_lambda : profile_cxx11_lambda.cpp
+ : <library>/boost/chrono//boost_chrono
+ <library>/boost/system//boost_system
+ <link>static
+ ;
+exe profile_local_function : profile_local_function.cpp
+ : <library>/boost/chrono//boost_chrono
+ <library>/boost/system//boost_system
+ <link>static
+ ;
+exe profile_local_function_inline : profile_local_function_inline.cpp
+ : <library>/boost/chrono//boost_chrono
+ <library>/boost/system//boost_system
+ <link>static
+ ;
+exe profile_local_functor : profile_local_functor.cpp
+ : <library>/boost/chrono//boost_chrono
+ <library>/boost/system//boost_system
+ <link>static
+ ;
+exe profile_phoenix : profile_phoenix.cpp
+ : <library>/boost/chrono//boost_chrono
+ <library>/boost/system//boost_system
+ <link>static
+ ;
+
+run scope_exit.cpp ;
+
diff --git a/libs/local_function/example/add_cxx11_lambda.cpp b/libs/local_function/example/add_cxx11_lambda.cpp
new file mode 100644
index 000000000..4a34cb5f0
--- /dev/null
+++ b/libs/local_function/example/add_cxx11_lambda.cpp
@@ -0,0 +1,34 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_LAMBDAS
+# error "lambda functions required"
+#else
+
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+
+//[add_cxx11_lambda
+int main(void) { // Some local scope.
+ int sum = 0, factor = 10; // Variables in scope to bind.
+
+ auto add = [factor, &sum](int num) { // C++11 only.
+ sum += factor * num;
+ };
+
+ add(1); // Call the lambda.
+ int nums[] = {2, 3};
+ std::for_each(nums, nums + 2, add); // Pass it to an algorithm.
+
+ BOOST_TEST(sum == 60); // Assert final summation value.
+ return boost::report_errors();
+}
+//]
+
+#endif
+
diff --git a/libs/local_function/example/add_global_functor.cpp b/libs/local_function/example/add_global_functor.cpp
new file mode 100644
index 000000000..229b31525
--- /dev/null
+++ b/libs/local_function/example/add_global_functor.cpp
@@ -0,0 +1,38 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+
+//[add_global_functor
+// Unfortunately, cannot be defined locally (so not a real alternative).
+struct global_add { // Unfortunately, boilerplate code to program the class.
+ global_add(int& _sum, int _factor): sum(_sum), factor(_factor) {}
+
+ inline void operator()(int num) { // Body uses C++ statement syntax.
+ sum += factor * num;
+ }
+
+private: // Unfortunately, cannot bind so repeat variable types.
+ int& sum; // Access `sum` by reference.
+ const int factor; // Make `factor` constant.
+};
+
+int main(void) {
+ int sum = 0, factor = 10;
+
+ global_add add(sum, factor);
+
+ add(1);
+ int nums[] = {2, 3};
+ std::for_each(nums, nums + 2, add); // Passed as template parameter.
+
+ BOOST_TEST(sum == 60);
+ return boost::report_errors();
+}
+//]
+
diff --git a/libs/local_function/example/add_local_functor.cpp b/libs/local_function/example/add_local_functor.cpp
new file mode 100644
index 000000000..e75f83f76
--- /dev/null
+++ b/libs/local_function/example/add_local_functor.cpp
@@ -0,0 +1,35 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/detail/lightweight_test.hpp>
+
+//[add_local_functor
+int main(void) {
+ int sum = 0, factor = 10;
+
+ struct local_add { // Unfortunately, boilerplate code to program the class.
+ local_add(int& _sum, int _factor): sum(_sum), factor(_factor) {}
+
+ inline void operator()(int num) { // Body uses C++ statement syntax.
+ sum += factor * num;
+ }
+
+ private: // Unfortunately, cannot bind so repeat variable types.
+ int& sum; // Access `sum` by reference.
+ const int factor; // Make `factor` constant.
+ } add(sum, factor);
+
+ add(1);
+ int nums[] = {2, 3};
+ // Unfortunately, cannot pass as template parameter to `std::for_each`.
+ for(size_t i = 0; i < 2; ++i) add(nums[i]);
+
+ BOOST_TEST(sum == 60);
+ return boost::report_errors();
+}
+//]
+
diff --git a/libs/local_function/example/add_phoenix.cpp b/libs/local_function/example/add_phoenix.cpp
new file mode 100644
index 000000000..10b534265
--- /dev/null
+++ b/libs/local_function/example/add_phoenix.cpp
@@ -0,0 +1,34 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/spirit/include/phoenix.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+#include <iostream>
+
+//[add_phoenix
+int main(void) {
+ using boost::phoenix::let;
+ using boost::phoenix::local_names::_f;
+ using boost::phoenix::cref;
+ using boost::phoenix::ref;
+ using boost::phoenix::arg_names::_1;
+
+ int sum = 0, factor = 10;
+ int nums[] = {1, 2, 3};
+
+ // Passed to template, `factor` by constant, and defined in expression.
+ std::for_each(nums, nums + 3, let(_f = cref(factor))[
+ // Unfortunately, body cannot use C++ statement syntax.
+ ref(sum) += _f * _1, _1 // Access `sum` by reference.
+ ]);
+
+ BOOST_TEST(sum == 60);
+ return boost::report_errors();
+}
+//]
+
diff --git a/libs/local_function/example/chrono.py b/libs/local_function/example/chrono.py
new file mode 100755
index 000000000..84d6dfb3a
--- /dev/null
+++ b/libs/local_function/example/chrono.py
@@ -0,0 +1,25 @@
+
+# Copyright (C) 2009-2012 Lorenzo Caminiti
+# Distributed under the Boost Software License, Version 1.0
+# (see accompanying file LICENSE_1_0.txt or a copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+# Home at http://www.boost.org/libs/local_function
+
+import sys
+import time
+import os
+
+if len(sys.argv) < 2:
+ print "Usage: python " + sys.argv[0] + " COMMAND [COMMAND_OPTIONS]"
+ print "Measure run-time of executing the specified command."
+ exit(1)
+
+cmd = ""
+for arg in sys.argv[1:]: cmd += str(arg) + " "
+
+start = time.time()
+ret = os.system(cmd)
+sec = time.time() - start
+
+if (ret == 0): print "\n" + str(sec) + "s"
+
diff --git a/libs/local_function/example/const_block.cpp b/libs/local_function/example/const_block.cpp
new file mode 100644
index 000000000..55fb5ec17
--- /dev/null
+++ b/libs/local_function/example/const_block.cpp
@@ -0,0 +1,18 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "const_block.hpp"
+#include <cassert>
+
+int main(void) {
+ int x = 0, y = 0;
+ CONST_BLOCK(x, y) {
+ assert(x == y);
+ } CONST_BLOCK_END
+ return 0;
+}
+
diff --git a/libs/local_function/example/const_block.hpp b/libs/local_function/example/const_block.hpp
new file mode 100644
index 000000000..904273410
--- /dev/null
+++ b/libs/local_function/example/const_block.hpp
@@ -0,0 +1,58 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#ifndef CONST_BLOCK_HPP_
+#define CONST_BLOCK_HPP_
+
+#include <boost/local_function.hpp>
+#include <boost/local_function/detail/preprocessor/void_list.hpp>
+#include <boost/local_function/detail/preprocessor/line_counter.hpp>
+#include <boost/preprocessor/list/for_each_i.hpp>
+#include <boost/preprocessor/list/adt.hpp>
+#include <boost/preprocessor/tuple/eat.hpp>
+#include <boost/preprocessor/punctuation/comma_if.hpp>
+#include <boost/preprocessor/control/iif.hpp>
+#include <boost/preprocessor/cat.hpp>
+
+// PRIVATE //
+
+#define CONST_BLOCK_BIND_(r, unused, i, var) \
+ BOOST_PP_COMMA_IF(i) const bind& var
+
+//[const_block_macro
+#define CONST_BLOCK_(variables) \
+ void BOOST_LOCAL_FUNCTION( \
+ BOOST_PP_IIF(BOOST_PP_LIST_IS_NIL(variables), \
+ void BOOST_PP_TUPLE_EAT(3) \
+ , \
+ BOOST_PP_LIST_FOR_EACH_I \
+ )(CONST_BLOCK_BIND_, ~, variables) \
+ )
+//]
+
+//[const_block_end_macro
+#define CONST_BLOCK_END_(id) \
+ BOOST_LOCAL_FUNCTION_NAME(BOOST_PP_CAT(const_block_, id)) \
+ BOOST_PP_CAT(const_block_, id)(); /* call local function immediately */
+//]
+
+// PUBLIC //
+
+// Arguments `void | var1, var2, ... | (var1) (var2) ...`.
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# define CONST_BLOCK(void_or_seq) \
+ CONST_BLOCK_(BOOST_LOCAL_FUNCTION_DETAIL_PP_VOID_LIST(void_or_seq))
+#else
+# define CONST_BLOCK(...) \
+ CONST_BLOCK_(BOOST_LOCAL_FUNCTION_DETAIL_PP_VOID_LIST(__VA_ARGS__))
+#endif
+
+#define CONST_BLOCK_END \
+ CONST_BLOCK_END_(BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER)
+
+#endif // #include guard
+
diff --git a/libs/local_function/example/const_block_error.cpp b/libs/local_function/example/const_block_error.cpp
new file mode 100644
index 000000000..3e70c5037
--- /dev/null
+++ b/libs/local_function/example/const_block_error.cpp
@@ -0,0 +1,20 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "const_block.hpp"
+#include <cassert>
+
+int main(void) {
+ //[const_block
+ int x = 1, y = 2;
+ CONST_BLOCK(x, y) { // Constant block.
+ assert(x = y); // Compiler error.
+ } CONST_BLOCK_END
+ //]
+ return 0;
+}
+
diff --git a/libs/local_function/example/const_block_error_cxx11_lambda.cpp b/libs/local_function/example/const_block_error_cxx11_lambda.cpp
new file mode 100644
index 000000000..d555cc876
--- /dev/null
+++ b/libs/local_function/example/const_block_error_cxx11_lambda.cpp
@@ -0,0 +1,28 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_LAMBDAS
+# error "requires lambda functions"
+#else
+
+#include <cassert>
+
+int main(void) {
+ //[const_block_cxx11_lambda
+ int x = 1, y = 2;
+ const decltype(x)& const_x = x; // Constant so cannot be modified
+ const decltype(y)& const_y = y; // and reference so no copy.
+ [&const_x, &const_y]() { // Lambda functions (C++11 only).
+ assert(const_x = const_y); // Unfortunately, `const_` names.
+ }();
+ //]
+ return 0;
+}
+
+#endif // LAMBDAS
+
diff --git a/libs/local_function/example/expensive_copy_cxx11_lambda.cpp b/libs/local_function/example/expensive_copy_cxx11_lambda.cpp
new file mode 100644
index 000000000..e1b40136e
--- /dev/null
+++ b/libs/local_function/example/expensive_copy_cxx11_lambda.cpp
@@ -0,0 +1,39 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_LAMBDAS
+# error "lambda functions required"
+#else
+
+#include <iostream>
+#include <cassert>
+
+//[expensive_copy_cxx11_lambda
+struct n {
+ int i;
+ n(int _i): i(_i) {}
+ n(n const& x): i(x.i) { // Some time consuming copy operation.
+ for (unsigned i = 0; i < 10000; ++i) std::cout << '.';
+ }
+};
+
+
+int main(void) {
+ n x(-1);
+
+ auto f = [x]() { // Problem: Expensive copy, but if bind
+ assert(x.i == -1); // by `&x` then `x` is not constant.
+ };
+ f();
+
+ return 0;
+}
+//]
+
+#endif // NO_LAMBDAS
+
diff --git a/libs/local_function/example/expensive_copy_local_function.cpp b/libs/local_function/example/expensive_copy_local_function.cpp
new file mode 100644
index 000000000..ed67fec9f
--- /dev/null
+++ b/libs/local_function/example/expensive_copy_local_function.cpp
@@ -0,0 +1,35 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <iostream>
+#include <cassert>
+
+//[expensive_copy_local_function
+struct n {
+ int i;
+ n(int _i): i(_i) {}
+ n(n const& x): i(x.i) { // Some time consuming copy operation.
+ for (unsigned i = 0; i < 10000; ++i) std::cout << '.';
+ }
+};
+BOOST_TYPEOF_REGISTER_TYPE(n) // Register for `bind& x` below.
+
+int main(void) {
+ n x(-1);
+
+ void BOOST_LOCAL_FUNCTION(const bind& x) { // OK: No copy expensive
+ assert(x.i == -1); // copy but constant.
+ } BOOST_LOCAL_FUNCTION_NAME(f)
+ f();
+
+ return 0;
+}
+//]
+
diff --git a/libs/local_function/example/gcc_access.cpp b/libs/local_function/example/gcc_access.cpp
new file mode 100644
index 000000000..0b0e171e2
--- /dev/null
+++ b/libs/local_function/example/gcc_access.cpp
@@ -0,0 +1,23 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main(void) {
+ int nums[] = {1, 2, 3};
+ int offset = -1;
+ int BOOST_LOCAL_FUNCTION(const bind offset, int* array, int index) {
+ return array[index + offset];
+ } BOOST_LOCAL_FUNCTION_NAME(access)
+
+ BOOST_TEST(access(nums, 1) == 1);
+ BOOST_TEST(access(nums, 2) == 2);
+ BOOST_TEST(access(nums, 3) == 3);
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/example/gcc_cxx11_lambda.cpp b/libs/local_function/example/gcc_cxx11_lambda.cpp
new file mode 100644
index 000000000..c6299b66f
--- /dev/null
+++ b/libs/local_function/example/gcc_cxx11_lambda.cpp
@@ -0,0 +1,35 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_LAMBDAS
+# error "lambda functions required"
+#else
+
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+
+int main(void) {
+ //[gcc_cxx11_lambda
+ int val = 2;
+ int nums[] = {1, 2, 3};
+ int* end = nums + 3;
+
+ int* iter = std::find_if(nums, end,
+ [val](int num) -> bool {
+ return num == val;
+ }
+ );
+ //]
+
+ BOOST_TEST(iter != end);
+ BOOST_TEST(*iter == val);
+ return boost::report_errors();
+}
+
+#endif // LAMBDAS
+
diff --git a/libs/local_function/example/gcc_lambda.cpp b/libs/local_function/example/gcc_lambda.cpp
new file mode 100644
index 000000000..602ad8172
--- /dev/null
+++ b/libs/local_function/example/gcc_lambda.cpp
@@ -0,0 +1,36 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifndef __GNUC__
+# error "GCC required (using non-standard GCC statement expressions)"
+#else
+
+#include "gcc_lambda.hpp"
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+
+int main(void) {
+ //[gcc_lambda
+ int val = 2;
+ int nums[] = {1, 2, 3};
+ int* end = nums + 3;
+
+ int* iter = std::find_if(nums, end,
+ GCC_LAMBDA(const bind val, int num, return bool) {
+ return num == val;
+ } GCC_LAMBDA_END
+ );
+ //]
+
+ BOOST_TEST(iter != end);
+ BOOST_TEST(*iter == val);
+ return boost::report_errors();
+}
+
+#endif // GCC
+
diff --git a/libs/local_function/example/gcc_lambda.hpp b/libs/local_function/example/gcc_lambda.hpp
new file mode 100644
index 000000000..665febc82
--- /dev/null
+++ b/libs/local_function/example/gcc_lambda.hpp
@@ -0,0 +1,129 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#ifndef GCC_LAMBDA_HPP_
+#define GCC_LAMBDA_HPP_
+
+#include <boost/local_function.hpp>
+#include <boost/local_function/detail/preprocessor/void_list.hpp>
+#include <boost/local_function/detail/preprocessor/line_counter.hpp>
+#include <boost/local_function/detail/preprocessor/keyword/return.hpp>
+#include <boost/local_function/detail/preprocessor/keyword/const_bind.hpp>
+#include <boost/local_function/detail/preprocessor/keyword/bind.hpp>
+#include <boost/preprocessor/list/for_each_i.hpp>
+#include <boost/preprocessor/list/fold_left.hpp>
+#include <boost/preprocessor/list/append.hpp>
+#include <boost/preprocessor/list/enum.hpp>
+#include <boost/preprocessor/list/adt.hpp>
+#include <boost/preprocessor/tuple/elem.hpp>
+#include <boost/preprocessor/tuple/eat.hpp>
+#include <boost/preprocessor/control/iif.hpp>
+#include <boost/preprocessor/punctuation/comma_if.hpp>
+#include <boost/preprocessor/facilities/expand.hpp>
+#include <boost/preprocessor/cat.hpp>
+#include <boost/config.hpp>
+
+// PRIVATE //
+
+#define GCC_LAMBDA_SPLIT_BIND_(elem, binds, params, results) \
+ (BOOST_PP_LIST_APPEND(binds, (elem, BOOST_PP_NIL)), params, results)
+
+#define GCC_LAMBDA_SPLIT_PARAM_(elem, binds, params, results) \
+ (binds, BOOST_PP_LIST_APPEND(params, (elem, BOOST_PP_NIL)), results)
+
+#define GCC_LAMBDA_SPLIT_RESULT_(elem, binds, params, results) \
+ (binds, params, BOOST_PP_LIST_APPEND(results, (elem, BOOT_PP_NIL)))
+
+#define GCC_LAMBDA_SPLIT_DISPATCH_(d, binds_params_results, elem) \
+ BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_IS_RETURN_FRONT(elem), \
+ GCC_LAMBDA_SPLIT_RESULT_ \
+ , BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_IS_BIND_FRONT(elem), \
+ GCC_LAMBDA_SPLIT_BIND_ \
+ , BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_IS_CONST_BIND_FRONT( \
+ elem), \
+ GCC_LAMBDA_SPLIT_BIND_ \
+ , /* no result, no bind, and no const bind so it's param */ \
+ GCC_LAMBDA_SPLIT_PARAM_ \
+ )))(elem, BOOST_PP_TUPLE_ELEM(3, 0, binds_params_results), \
+ BOOST_PP_TUPLE_ELEM(3, 1, binds_params_results), \
+ BOOST_PP_TUPLE_ELEM(3, 2, binds_params_results))
+
+#define GCC_LAMBDA_SPLIT_(list) \
+ BOOST_PP_LIST_FOLD_LEFT(GCC_LAMBDA_SPLIT_DISPATCH_, \
+ (BOOST_PP_NIL, BOOST_PP_NIL, BOOST_PP_NIL), list)
+
+#define GCC_LAMBDA_REMOVE_CONST_BIND_(r, unused, i, elem) \
+ BOOST_PP_COMMA_IF(i) \
+ BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_CONST_BIND_REMOVE_FRONT(elem)
+
+#define GCC_LAMBDA_RESULT_TYPE_(results) \
+ BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_RETURN_REMOVE_FRONT( \
+ BOOST_PP_LIST_FIRST(results))
+
+#ifdef BOOST_NO_CXX11_LAMBDAS
+//[gcc_lambda_macro
+# define GCC_LAMBDA_(binds, params, results) \
+ ({ /* open statement expression (GCC extension only) */ \
+ BOOST_LOCAL_FUNCTION( \
+ BOOST_PP_LIST_ENUM(BOOST_PP_LIST_APPEND(binds, \
+ BOOST_PP_LIST_APPEND(params, \
+ BOOST_PP_IIF(BOOST_PP_LIST_IS_NIL(results), \
+ (return void, BOOST_PP_NIL) /* default for lambdas */ \
+ , \
+ results \
+ )\
+ ) \
+ )) \
+ )
+//]
+#else
+# define GCC_LAMBDA_(binds, params, results) \
+ /* ignore const binding because not supported by C++11 lambdas */ \
+ [ BOOST_PP_LIST_FOR_EACH_I(GCC_LAMBDA_REMOVE_CONST_BIND_, ~, binds) ] \
+ ( BOOST_PP_LIST_ENUM(params) ) \
+ BOOST_PP_IIF(BOOST_PP_LIST_IS_NIL(results), \
+ BOOST_PP_TUPLE_EAT(1) /* void result type (default) */ \
+ , \
+ -> GCC_LAMBDA_RESULT_TYPE_ \
+ )(results)
+#endif
+
+#define GCC_LAMBDA_TUPLE_(binds_params_results) \
+ GCC_LAMBDA_(BOOST_PP_TUPLE_ELEM(3, 0, binds_params_results), \
+ BOOST_PP_TUPLE_ELEM(3, 1, binds_params_results), \
+ BOOST_PP_TUPLE_ELEM(3, 2, binds_params_results))
+
+//[gcc_lambda_end_macro
+#define GCC_LAMBDA_END_(id) \
+ BOOST_LOCAL_FUNCTION_NAME(BOOST_PP_CAT(gcc_lambda_, id)) \
+ BOOST_PP_CAT(gcc_lambda_, id); \
+ }) /* close statement expression (GCC extension only) */
+//]
+
+// PUBLIC //
+
+// Same arguments as for local functions but respect to C++11 lambdas:
+// const bind v is =v, bind& v is &v, void if no return specified, no = or &.
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# define GCC_LAMBDA(void_or_seq) \
+ GCC_LAMBDA_TUPLE_(GCC_LAMBDA_SPLIT_( \
+ BOOST_LOCAL_FUNCTION_DETAIL_PP_VOID_LIST(void_or_seq)))
+#else
+# define GCC_LAMBDA(...) \
+ GCC_LAMBDA_TUPLE_(GCC_LAMBDA_SPLIT_( \
+ BOOST_LOCAL_FUNCTION_DETAIL_PP_VOID_LIST(__VA_ARGS__)))
+#endif
+
+#ifdef BOOST_NO_CXX11_LAMBDAS
+# define GCC_LAMBDA_END \
+ GCC_LAMBDA_END_(BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER)
+#else
+# define GCC_LAMBDA_END /* nothing */
+#endif
+
+#endif // #include guard
+
diff --git a/libs/local_function/example/gcc_square.cpp b/libs/local_function/example/gcc_square.cpp
new file mode 100644
index 000000000..6bd16e88d
--- /dev/null
+++ b/libs/local_function/example/gcc_square.cpp
@@ -0,0 +1,23 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int add_square(int a, int b) {
+ int BOOST_LOCAL_FUNCTION(int z) {
+ return z * z;
+ } BOOST_LOCAL_FUNCTION_NAME(square)
+
+ return square(a) + square(b);
+}
+
+int main(void) {
+ BOOST_TEST(add_square(2, 4) == 20);
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/example/gcc_store.cpp b/libs/local_function/example/gcc_store.cpp
new file mode 100644
index 000000000..57b68ad2e
--- /dev/null
+++ b/libs/local_function/example/gcc_store.cpp
@@ -0,0 +1,33 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+void intermediate(boost::function<void (int, int)> store_func, int size) {
+ store_func(size - 1, -1);
+}
+
+void hack(int* array, int size) {
+ void BOOST_LOCAL_FUNCTION(bind array, int index, int value) {
+ array[index] = value;
+ } BOOST_LOCAL_FUNCTION_NAME(store)
+
+ intermediate(store, size);
+}
+
+int main(void) {
+ int nums[] = {1, 2, 3};
+ hack(nums, 3);
+
+ BOOST_TEST(nums[0] == 1);
+ BOOST_TEST(nums[1] == 2);
+ BOOST_TEST(nums[2] == -1);
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/example/impl_pp_keyword.cpp b/libs/local_function/example/impl_pp_keyword.cpp
new file mode 100644
index 000000000..7a03ae77b
--- /dev/null
+++ b/libs/local_function/example/impl_pp_keyword.cpp
@@ -0,0 +1,28 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+//[impl_pp_keyword
+#include <boost/local_function/detail/preprocessor/keyword/thisunderscore.hpp>
+#include <boost/local_function/detail/preprocessor/keyword/const.hpp>
+#include <boost/local_function/detail/preprocessor/keyword/bind.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+// Expand to 1 if space-separated tokens end with `this_`, 0 otherwise.
+#define IS_THIS_BACK(tokens) \
+ BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_IS_THISUNDERSCORE_BACK( \
+ BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_BIND_REMOVE_FRONT( \
+ BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_CONST_REMOVE_FRONT( \
+ tokens \
+ )))
+
+int main(void) {
+ BOOST_TEST(IS_THIS_BACK(const bind this_) == 1);
+ BOOST_TEST(IS_THIS_BACK(const bind& x) == 0);
+ return boost::report_errors();
+}
+//]
+
diff --git a/libs/local_function/example/impl_tparam_tricks.cpp b/libs/local_function/example/impl_tparam_tricks.cpp
new file mode 100644
index 000000000..aa394df2d
--- /dev/null
+++ b/libs/local_function/example/impl_tparam_tricks.cpp
@@ -0,0 +1,71 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+//[impl_tparam_tricks
+#include <boost/detail/lightweight_test.hpp>
+#include <vector>
+#include <algorithm>
+
+// Casting functor trick.
+struct casting_func {
+ explicit casting_func(void* obj, void (*call)(void*, const int&))
+ : obj_(obj), call_(call) {}
+ // Unfortunately, function pointer call is not inlined.
+ inline void operator()(const int& num) { call_(obj_, num); }
+private:
+ void* obj_;
+ void (*call_)(void*, const int&);
+};
+
+// Virtual functor trick.
+struct virtual_func {
+ struct interface {
+ // Unfortunately, virtual function call is not inlined.
+ inline virtual void operator()(const int&) {}
+ };
+ explicit virtual_func(interface& func): func_(&func) {}
+ inline void operator()(const int& num) { (*func_)(num); }
+private:
+ interface* func_;
+};
+
+int main(void) {
+ int sum = 0, factor = 10;
+
+ // Local class for local function.
+ struct local_add : virtual_func::interface {
+ explicit local_add(int& _sum, const int& _factor)
+ : sum_(_sum), factor_(_factor) {}
+ inline void operator()(const int& num) {
+ body(sum_, factor_, num);
+ }
+ inline static void call(void* obj, const int& num) {
+ local_add* self = static_cast<local_add*>(obj);
+ self->body(self->sum_, self->factor_, num);
+ }
+ private:
+ int& sum_;
+ const int& factor_;
+ inline void body(int& sum, const int& factor, const int& num) {
+ sum += factor * num;
+ }
+ } add_local(sum, factor);
+ casting_func add_casting(&add_local, &local_add::call);
+ virtual_func add_virtual(add_local);
+
+ std::vector<int> v(10);
+ std::fill(v.begin(), v.end(), 1);
+
+ // std::for_each(v.begin(), v.end(), add_local); // Error but OK on C++11.
+ std::for_each(v.begin(), v.end(), add_casting); // OK.
+ std::for_each(v.begin(), v.end(), add_virtual); // OK.
+
+ BOOST_TEST(sum == 200);
+ return boost::report_errors();
+}
+//]
+
diff --git a/libs/local_function/example/n2529_this.cpp b/libs/local_function/example/n2529_this.cpp
new file mode 100644
index 000000000..1a954ad3e
--- /dev/null
+++ b/libs/local_function/example/n2529_this.cpp
@@ -0,0 +1,47 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+#include <vector>
+#include <algorithm>
+
+struct v;
+BOOST_TYPEOF_REGISTER_TYPE(v) // Register before `bind this_` below.
+
+struct v {
+ std::vector<int> nums;
+
+ v(const std::vector<int>& numbers): nums(numbers) {}
+
+ void change_sign_all(const std::vector<int>& indices) {
+ void BOOST_LOCAL_FUNCTION(bind this_, int i) { // Bind object `this`.
+ this_->nums.at(i) = -this_->nums.at(i);
+ } BOOST_LOCAL_FUNCTION_NAME(complement)
+
+ std::for_each(indices.begin(), indices.end(), complement);
+ }
+};
+
+int main(void) {
+ std::vector<int> n(3);
+ n[0] = 1; n[1] = 2; n[2] = 3;
+
+ std::vector<int> i(2);
+ i[0] = 0; i[1] = 2; // Will change n[0] and n[2] but not n[1].
+
+ v vn(n);
+ vn.change_sign_all(i);
+
+ BOOST_TEST(vn.nums.at(0) == -1);
+ BOOST_TEST(vn.nums.at(1) == 2);
+ BOOST_TEST(vn.nums.at(2) == -3);
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/example/n2550_find_if.cpp b/libs/local_function/example/n2550_find_if.cpp
new file mode 100644
index 000000000..f372707a3
--- /dev/null
+++ b/libs/local_function/example/n2550_find_if.cpp
@@ -0,0 +1,44 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+#include <vector>
+#include <algorithm>
+
+struct employee {
+ int salary;
+ explicit employee(const int& a_salary): salary(a_salary) {}
+};
+BOOST_TYPEOF_REGISTER_TYPE(employee) // Register for `NAME` below.
+
+int main(void) {
+ std::vector<employee> employees;
+ employees.push_back(employee(85000));
+ employees.push_back(employee(100000));
+ employees.push_back(employee(120000));
+
+ int min_salary = 100000;
+ int u_limit = min_salary + 1;
+
+ bool BOOST_LOCAL_FUNCTION(const bind& min_salary, const bind& u_limit,
+ const employee& e) {
+ return e.salary >= min_salary && e.salary < u_limit;
+ } BOOST_LOCAL_FUNCTION_NAME(between)
+
+ // Pass local function to an STL algorithm as a template paramter (this
+ // cannot be done with plain member functions of local classes).
+ std::vector<employee>::iterator i = std::find_if(
+ employees.begin(), employees.end(), between);
+
+ BOOST_TEST(i != employees.end());
+ BOOST_TEST(i->salary >= min_salary && i->salary < u_limit);
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/example/noncopyable_cxx11_lambda_error.cpp b/libs/local_function/example/noncopyable_cxx11_lambda_error.cpp
new file mode 100644
index 000000000..706079ebc
--- /dev/null
+++ b/libs/local_function/example/noncopyable_cxx11_lambda_error.cpp
@@ -0,0 +1,36 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_LAMBDAS
+# error "lambda functions required"
+#else
+
+#include <boost/noncopyable.hpp>
+#include <cassert>
+
+//[noncopyable_cxx11_lambda_error
+struct n: boost::noncopyable {
+ int i;
+ n(int _i): i(_i) {}
+};
+
+
+int main(void) {
+ n x(-1);
+
+ auto f = [x](void) { // Error: x is non-copyable, but if
+ assert(x.i == -1); // bind `&x` then `x` is not constant.
+ };
+ f();
+
+ return 0;
+}
+//]
+
+#endif // LAMBDAS
+
diff --git a/libs/local_function/example/noncopyable_local_function.cpp b/libs/local_function/example/noncopyable_local_function.cpp
new file mode 100644
index 000000000..b4ef9ad5a
--- /dev/null
+++ b/libs/local_function/example/noncopyable_local_function.cpp
@@ -0,0 +1,32 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/noncopyable.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <cassert>
+
+//[noncopyable_local_function
+struct n: boost::noncopyable {
+ int i;
+ n(int _i): i(_i) {}
+};
+BOOST_TYPEOF_REGISTER_TYPE(n) // Register for `bind& x` below.
+
+int main(void) {
+ n x(-1);
+
+ void BOOST_LOCAL_FUNCTION(const bind& x) { // OK: No copy
+ assert(x.i == -1); // and constant.
+ } BOOST_LOCAL_FUNCTION_NAME(f)
+ f();
+
+ return 0;
+}
+//]
+
diff --git a/libs/local_function/example/phoenix_factorial.cpp b/libs/local_function/example/phoenix_factorial.cpp
new file mode 100644
index 000000000..bdc8306f6
--- /dev/null
+++ b/libs/local_function/example/phoenix_factorial.cpp
@@ -0,0 +1,40 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+//[phoenix_factorial
+struct factorial_impl { // Phoenix function from global functor.
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Arg>
+ struct result<This (Arg)> : result<This (Arg const&)> {};
+
+ template<typename This, typename Arg>
+ struct result<This (Arg&)> { typedef Arg type; };
+
+ template<typename Arg> // Polymorphic.
+ Arg operator()(Arg n) const {
+ return (n <= 0) ? 1 : n * (*this)(n - 1);
+ }
+};
+
+int main(void) {
+ using boost::phoenix::arg_names::arg1;
+
+ boost::phoenix::function<factorial_impl> factorial;
+
+ int i = 4;
+ BOOST_TEST(factorial(i)() == 24); // Call.
+ BOOST_TEST(factorial(arg1)(i) == 24); // Lazy call.
+ return boost::report_errors();
+}
+//]
+
diff --git a/libs/local_function/example/phoenix_factorial_local.cpp b/libs/local_function/example/phoenix_factorial_local.cpp
new file mode 100644
index 000000000..c52c094b5
--- /dev/null
+++ b/libs/local_function/example/phoenix_factorial_local.cpp
@@ -0,0 +1,31 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/function.hpp>
+#include <boost/phoenix/core.hpp>
+#include <boost/phoenix/function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+//[phoenix_factorial_local
+int main(void) {
+ using boost::phoenix::arg_names::arg1;
+
+ int BOOST_LOCAL_FUNCTION(int n) { // Unfortunately, monomorphic.
+ return (n <= 0) ? 1 : n * factorial_impl(n - 1);
+ } BOOST_LOCAL_FUNCTION_NAME(recursive factorial_impl)
+
+ boost::phoenix::function< boost::function<int (int)> >
+ factorial(factorial_impl); // Phoenix function from local function.
+
+ int i = 4;
+ BOOST_TEST(factorial(i)() == 24); // Call.
+ BOOST_TEST(factorial(arg1)(i) == 24); // Lazy call.
+ return boost::report_errors();
+}
+//]
+
diff --git a/libs/local_function/example/profile.xls b/libs/local_function/example/profile.xls
new file mode 100644
index 000000000..9087ed174
--- /dev/null
+++ b/libs/local_function/example/profile.xls
Binary files differ
diff --git a/libs/local_function/example/profile_cxx11_lambda.cpp b/libs/local_function/example/profile_cxx11_lambda.cpp
new file mode 100644
index 000000000..f2c1c26e5
--- /dev/null
+++ b/libs/local_function/example/profile_cxx11_lambda.cpp
@@ -0,0 +1,44 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_LAMBDAS
+# error "lambda functions required"
+#else
+
+#include <boost/chrono.hpp>
+#include <vector>
+#include <algorithm>
+#include <iostream>
+#include "profile_helpers.hpp"
+
+int main(int argc, char* argv[]) {
+ unsigned long size = 0, trials = 0;
+ profile::args(argc, argv, size, trials);
+
+ double sum = 0.0;
+ int factor = 1;
+
+ std::vector<double> v(size);
+ std::fill(v.begin(), v.end(), 1.0);
+
+ boost::chrono::duration<double> trials_sec;
+ for(unsigned long i = 0; i < trials; ++i) {
+ boost::chrono::system_clock::time_point start =
+ boost::chrono::system_clock::now();
+ std::for_each(v.begin(), v.end(), [&sum, factor](const double& num) {
+ sum += factor * num;
+ });
+ trials_sec += boost::chrono::system_clock::now() - start;
+ }
+
+ profile::display(size, trials, sum, trials_sec.count());
+ return 0;
+}
+
+#endif // LAMBDAS
+
diff --git a/libs/local_function/example/profile_gcc_cxx11_debug.png b/libs/local_function/example/profile_gcc_cxx11_debug.png
new file mode 100644
index 000000000..431f2bb37
--- /dev/null
+++ b/libs/local_function/example/profile_gcc_cxx11_debug.png
Binary files differ
diff --git a/libs/local_function/example/profile_gcc_cxx11_release.png b/libs/local_function/example/profile_gcc_cxx11_release.png
new file mode 100644
index 000000000..eeb371a4a
--- /dev/null
+++ b/libs/local_function/example/profile_gcc_cxx11_release.png
Binary files differ
diff --git a/libs/local_function/example/profile_gcc_debug.png b/libs/local_function/example/profile_gcc_debug.png
new file mode 100644
index 000000000..f907ca139
--- /dev/null
+++ b/libs/local_function/example/profile_gcc_debug.png
Binary files differ
diff --git a/libs/local_function/example/profile_gcc_release.png b/libs/local_function/example/profile_gcc_release.png
new file mode 100644
index 000000000..1a23e56b1
--- /dev/null
+++ b/libs/local_function/example/profile_gcc_release.png
Binary files differ
diff --git a/libs/local_function/example/profile_global_functor.cpp b/libs/local_function/example/profile_global_functor.cpp
new file mode 100644
index 000000000..6e104e4b4
--- /dev/null
+++ b/libs/local_function/example/profile_global_functor.cpp
@@ -0,0 +1,51 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/chrono.hpp>
+#include <vector>
+#include <algorithm>
+#include <iostream>
+#include "profile_helpers.hpp"
+
+struct global_add {
+ global_add(double& _sum, const int& _factor): sum(_sum), factor(_factor) {}
+ inline void operator()(const double& num) {
+ sum += factor * num;
+ }
+private:
+ double& sum;
+ const int& factor;
+};
+
+int main(int argc, char* argv[]) {
+ unsigned long size = 0, trials =0;
+ profile::args(argc, argv, size, trials);
+
+ double sum = 0.0;
+ int factor = 1;
+
+ boost::chrono::system_clock::time_point start =
+ boost::chrono::system_clock::now();
+ global_add add(sum, factor);
+ boost::chrono::duration<double> decl_sec =
+ boost::chrono::system_clock::now() - start;
+
+ std::vector<double> v(size);
+ std::fill(v.begin(), v.end(), 1.0);
+
+ boost::chrono::duration<double> trials_sec;
+ for(unsigned long i = 0; i < trials; ++i) {
+ boost::chrono::system_clock::time_point start =
+ boost::chrono::system_clock::now();
+ std::for_each(v.begin(), v.end(), add);
+ trials_sec += boost::chrono::system_clock::now() - start;
+ }
+
+ profile::display(size, trials, sum, trials_sec.count(), decl_sec.count());
+ return 0;
+}
+
diff --git a/libs/local_function/example/profile_helpers.hpp b/libs/local_function/example/profile_helpers.hpp
new file mode 100644
index 000000000..fe7969de5
--- /dev/null
+++ b/libs/local_function/example/profile_helpers.hpp
@@ -0,0 +1,54 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#ifndef PROFILE_HELPERS_HPP_
+#define PROFILE_HELPERS_HPP_
+
+#include <iostream>
+#include <cassert>
+
+namespace profile {
+
+void args(int argc, char* argv[], unsigned long& size, unsigned long& trials) {
+ size = 100000000; // Defaults.
+ trials = 10; // Default.
+ if (argc != 1 && argc != 2 && argc != 3) {
+ std::cerr << "ERROR: Incorrect argument(s)" << std::endl;
+ std::cerr << "Usage: " << argv[0] << " [SIZE] [TRIALS]" <<
+ std::endl;
+ std::cerr << "Defaults: SIZE = " << double(size) << ", TRIALS = " <<
+ double(trials) << std::endl;
+ exit(1);
+ }
+ if (argc >= 2) size = atol(argv[1]);
+ if (argc >= 3) trials = atol(argv[2]);
+
+ std::clog << "vector size = " << double(size) << std::endl;
+ std::clog << "number of trials = " << double(trials) << std::endl;
+ std::clog << "number of calls = " << double(size) * double(trials) <<
+ std::endl;
+}
+
+void display(const unsigned long& size, const unsigned long& trials,
+ const double& sum, const double& trials_sec,
+ const double& decl_sec = 0.0) {
+ std::clog << "sum = " << sum << std::endl;
+ std::clog << "declaration run-time [s] = " << decl_sec << std::endl;
+ std::clog << "trials run-time [s] = " << trials_sec << std::endl;
+
+ double avg_sec = decl_sec + trials_sec / trials;
+ std::clog << "average run-time [s] = declaration run-time + trials " <<
+ "run-time / number of trials = " << std::endl;
+ std::cout << avg_sec << std::endl; // To cout so it can be parsed easily.
+
+ assert(sum == double(size) * double(trials));
+}
+
+} // namespace
+
+#endif // #include guard
+
diff --git a/libs/local_function/example/profile_legend_cxx11_lambda.png b/libs/local_function/example/profile_legend_cxx11_lambda.png
new file mode 100644
index 000000000..58770b195
--- /dev/null
+++ b/libs/local_function/example/profile_legend_cxx11_lambda.png
Binary files differ
diff --git a/libs/local_function/example/profile_legend_global_functor.png b/libs/local_function/example/profile_legend_global_functor.png
new file mode 100644
index 000000000..d7f5b70fd
--- /dev/null
+++ b/libs/local_function/example/profile_legend_global_functor.png
Binary files differ
diff --git a/libs/local_function/example/profile_legend_local_function.png b/libs/local_function/example/profile_legend_local_function.png
new file mode 100644
index 000000000..5b9b51766
--- /dev/null
+++ b/libs/local_function/example/profile_legend_local_function.png
Binary files differ
diff --git a/libs/local_function/example/profile_legend_local_function_inline.png b/libs/local_function/example/profile_legend_local_function_inline.png
new file mode 100644
index 000000000..809de56d9
--- /dev/null
+++ b/libs/local_function/example/profile_legend_local_function_inline.png
Binary files differ
diff --git a/libs/local_function/example/profile_legend_local_functor.png b/libs/local_function/example/profile_legend_local_functor.png
new file mode 100644
index 000000000..6038c5776
--- /dev/null
+++ b/libs/local_function/example/profile_legend_local_functor.png
Binary files differ
diff --git a/libs/local_function/example/profile_legend_phoenix.png b/libs/local_function/example/profile_legend_phoenix.png
new file mode 100644
index 000000000..249962540
--- /dev/null
+++ b/libs/local_function/example/profile_legend_phoenix.png
Binary files differ
diff --git a/libs/local_function/example/profile_local_function.cpp b/libs/local_function/example/profile_local_function.cpp
new file mode 100644
index 000000000..1e2029a54
--- /dev/null
+++ b/libs/local_function/example/profile_local_function.cpp
@@ -0,0 +1,45 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/chrono.hpp>
+#include <vector>
+#include <algorithm>
+#include <iostream>
+#include "profile_helpers.hpp"
+
+int main(int argc, char* argv[]) {
+ unsigned long size = 0, trials = 0;
+ profile::args(argc, argv, size, trials);
+
+ double sum = 0.0;
+ int factor = 1;
+
+ boost::chrono::system_clock::time_point start =
+ boost::chrono::system_clock::now();
+ void BOOST_LOCAL_FUNCTION(
+ const double& num, bind& sum, const bind& factor) {
+ sum += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+ boost::chrono::duration<double> decl_sec =
+ boost::chrono::system_clock::now() - start;
+
+ std::vector<double> v(size);
+ std::fill(v.begin(), v.end(), 1.0);
+
+ boost::chrono::duration<double> trials_sec;
+ for(unsigned long i = 0; i < trials; ++i) {
+ boost::chrono::system_clock::time_point start =
+ boost::chrono::system_clock::now();
+ std::for_each(v.begin(), v.end(), add);
+ trials_sec += boost::chrono::system_clock::now() - start;
+ }
+
+ profile::display(size, trials, sum, trials_sec.count(), decl_sec.count());
+ return 0;
+}
+
diff --git a/libs/local_function/example/profile_local_function_inline.cpp b/libs/local_function/example/profile_local_function_inline.cpp
new file mode 100644
index 000000000..8b113ac7a
--- /dev/null
+++ b/libs/local_function/example/profile_local_function_inline.cpp
@@ -0,0 +1,45 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/chrono.hpp>
+#include <vector>
+#include <algorithm>
+#include <iostream>
+#include "profile_helpers.hpp"
+
+int main(int argc, char* argv[]) {
+ unsigned long size = 0, trials = 0;
+ profile::args(argc, argv, size, trials);
+
+ double sum = 0.0;
+ int factor = 1;
+
+ boost::chrono::system_clock::time_point start =
+ boost::chrono::system_clock::now();
+ void BOOST_LOCAL_FUNCTION(
+ const double& num, bind& sum, const bind& factor) {
+ sum += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME(inline add) // Inlined.
+ boost::chrono::duration<double> decl_sec =
+ boost::chrono::system_clock::now() - start;
+
+ std::vector<double> v(size);
+ std::fill(v.begin(), v.end(), 1.0);
+
+ boost::chrono::duration<double> trials_sec;
+ for(unsigned long i = 0; i < trials; ++i) {
+ boost::chrono::system_clock::time_point start =
+ boost::chrono::system_clock::now();
+ for(unsigned long j = 0; j < v.size(); ++j) add(v[j]); // No for_each.
+ trials_sec += boost::chrono::system_clock::now() - start;
+ }
+
+ profile::display(size, trials, sum, trials_sec.count(), decl_sec.count());
+ return 0;
+}
+
diff --git a/libs/local_function/example/profile_local_functor.cpp b/libs/local_function/example/profile_local_functor.cpp
new file mode 100644
index 000000000..abdef0bb7
--- /dev/null
+++ b/libs/local_function/example/profile_local_functor.cpp
@@ -0,0 +1,50 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/chrono.hpp>
+#include <vector>
+#include <algorithm>
+#include <iostream>
+#include "profile_helpers.hpp"
+
+int main(int argc, char* argv[]) {
+ unsigned long size = 0, trials = 0;
+ profile::args(argc, argv, size, trials);
+
+ double sum = 0.0;
+ int factor = 1;
+
+ boost::chrono::system_clock::time_point start =
+ boost::chrono::system_clock::now();
+ struct local_add {
+ local_add(double& _sum, const int& _factor):
+ sum(_sum), factor(_factor) {}
+ inline void operator()(const double& num) {
+ sum += factor * num;
+ }
+ private:
+ double& sum;
+ const int& factor;
+ } add(sum, factor);
+ boost::chrono::duration<double> decl_sec =
+ boost::chrono::system_clock::now() - start;
+
+ std::vector<double> v(size);
+ std::fill(v.begin(), v.end(), 1.0);
+
+ boost::chrono::duration<double> trials_sec;
+ for(unsigned long i = 0; i < trials; ++i) {
+ boost::chrono::system_clock::time_point start =
+ boost::chrono::system_clock::now();
+ for(unsigned long j = 0; j < v.size(); ++j) add(v[j]); // No for_each.
+ trials_sec += boost::chrono::system_clock::now() - start;
+ }
+
+ profile::display(size, trials, sum, trials_sec.count(), decl_sec.count());
+ return 0;
+}
+
diff --git a/libs/local_function/example/profile_msvc_debug.png b/libs/local_function/example/profile_msvc_debug.png
new file mode 100644
index 000000000..859744b73
--- /dev/null
+++ b/libs/local_function/example/profile_msvc_debug.png
Binary files differ
diff --git a/libs/local_function/example/profile_msvc_release.png b/libs/local_function/example/profile_msvc_release.png
new file mode 100644
index 000000000..ea14d44a1
--- /dev/null
+++ b/libs/local_function/example/profile_msvc_release.png
Binary files differ
diff --git a/libs/local_function/example/profile_phoenix.cpp b/libs/local_function/example/profile_phoenix.cpp
new file mode 100644
index 000000000..7bd2088a6
--- /dev/null
+++ b/libs/local_function/example/profile_phoenix.cpp
@@ -0,0 +1,45 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/spirit/home/phoenix/statement/sequence.hpp>
+#include <boost/spirit/home/phoenix/core/reference.hpp>
+#include <boost/spirit/home/phoenix/core/argument.hpp>
+#include <boost/spirit/home/phoenix/operator/arithmetic.hpp>
+#include <boost/chrono.hpp>
+#include <iostream>
+#include <vector>
+#include <algorithm>
+#include "profile_helpers.hpp"
+
+int main(int argc, char* argv[]) {
+ unsigned long size = 0, trials = 0;
+ profile::args(argc, argv, size, trials);
+
+ double sum = 0.0;
+ int factor = 1;
+
+ std::vector<double> v(size);
+ std::fill(v.begin(), v.end(), 1.0);
+
+ boost::chrono::duration<double> trials_sec;
+ for(unsigned long i = 0; i < trials; ++i) {
+ boost::chrono::system_clock::time_point start =
+ boost::chrono::system_clock::now();
+
+ using boost::phoenix::ref;
+ using boost::phoenix::arg_names::_1;
+ std::for_each(v.begin(), v.end(), (
+ ref(sum) += factor * _1
+ ));
+
+ trials_sec += boost::chrono::system_clock::now() - start;
+ }
+
+ profile::display(size, trials, sum, trials_sec.count());
+ return 0;
+}
+
diff --git a/libs/local_function/example/scope_exit.cpp b/libs/local_function/example/scope_exit.cpp
new file mode 100644
index 000000000..607bf6be0
--- /dev/null
+++ b/libs/local_function/example/scope_exit.cpp
@@ -0,0 +1,110 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "scope_exit.hpp"
+#include <boost/foreach.hpp>
+#include <boost/typeof/typeof.hpp>
+#include <boost/typeof/std/vector.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+#include <vector>
+#include <iostream>
+#include <sstream>
+
+class person {
+ friend class world;
+public:
+ typedef unsigned int id_t;
+ typedef unsigned int evolution_t;
+
+ person(void): id_(0), evolution_(0) {}
+
+ friend std::ostream& operator<<(std::ostream& o, person const& p) {
+ return o << "person(" << p.id_ << ", " << p.evolution_ << ")";
+ }
+private:
+ id_t id_;
+ evolution_t evolution_;
+};
+BOOST_TYPEOF_REGISTER_TYPE(person)
+
+class world {
+public:
+ typedef unsigned int id_t;
+
+ world(void): next_id_(1) {}
+
+ void add_person(person const& a_person);
+
+ friend std::ostream& operator<<(std::ostream& o, world const& w) {
+ o << "world(" << w.next_id_ << ", {";
+ BOOST_FOREACH(person const& p, w.persons_) {
+ o << " " << p << ", ";
+ }
+ return o << "})";
+ }
+private:
+ id_t next_id_;
+ std::vector<person> persons_;
+};
+BOOST_TYPEOF_REGISTER_TYPE(world)
+
+void world::add_person(person const& a_person) {
+ persons_.push_back(a_person);
+
+ // This block must be no-throw.
+ //[scope_exit
+ person& p = persons_.back();
+ person::evolution_t checkpoint = p.evolution_;
+
+ SCOPE_EXIT(const bind checkpoint, const bind& p, bind this_) {
+ if (checkpoint == p.evolution_) this_->persons_.pop_back();
+ } SCOPE_EXIT_END
+ //]
+
+ // ...
+
+ checkpoint = ++p.evolution_;
+
+ // Assign new id to the person.
+ world::id_t const prev_id = p.id_;
+ p.id_ = next_id_++;
+ SCOPE_EXIT(const bind checkpoint, const bind prev_id, bind& p,
+ bind& next_id_) {
+ if (checkpoint == p.evolution_) {
+ next_id_ = p.id_;
+ p.id_ = prev_id;
+ }
+ } SCOPE_EXIT_END
+
+ // ...
+
+ checkpoint = ++p.evolution_;
+}
+
+int main(void) {
+ person adam, eva;
+ std::ostringstream oss;
+ oss << adam;
+ std::cout << oss.str() << std::endl;
+ BOOST_TEST(oss.str() == "person(0, 0)");
+
+ oss.str("");
+ oss << eva;
+ std::cout << oss.str() << std::endl;
+ BOOST_TEST(oss.str() == "person(0, 0)");
+
+ world w;
+ w.add_person(adam);
+ w.add_person(eva);
+ oss.str("");
+ oss << w;
+ std::cout << oss.str() << std::endl;
+ BOOST_TEST(oss.str() == "world(3, { person(1, 2), person(2, 2), })");
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/example/scope_exit.hpp b/libs/local_function/example/scope_exit.hpp
new file mode 100644
index 000000000..5876b1406
--- /dev/null
+++ b/libs/local_function/example/scope_exit.hpp
@@ -0,0 +1,51 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#ifndef SCOPE_EXIT_HPP_
+#define SCOPE_EXIT_HPP_
+
+#include <boost/local_function.hpp>
+#include <boost/local_function/detail/preprocessor/line_counter.hpp>
+#include <boost/function.hpp>
+#include <boost/preprocessor/cat.hpp>
+#include <boost/config.hpp>
+
+//[scope_exit_class
+struct scope_exit {
+ scope_exit(boost::function<void (void)> f): f_(f) {}
+ ~scope_exit(void) { f_(); }
+private:
+ boost::function<void (void)> f_;
+};
+//]
+
+// PRIVATE //
+
+//[scope_exit_end_macro
+#define SCOPE_EXIT_END_(id) \
+ BOOST_LOCAL_FUNCTION_NAME(BOOST_PP_CAT(scope_exit_func_, id)) \
+ scope_exit BOOST_PP_CAT(scope_exit_, id)( \
+ BOOST_PP_CAT(scope_exit_func_, id));
+//]
+
+// PUBLIC //
+
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# define SCOPE_EXIT(void_or_seq) \
+ void BOOST_LOCAL_FUNCTION(void_or_seq)
+#else
+//[scope_exit_macro
+# define SCOPE_EXIT(...) \
+ void BOOST_LOCAL_FUNCTION(__VA_ARGS__)
+//]
+#endif
+
+#define SCOPE_EXIT_END \
+ SCOPE_EXIT_END_(BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER)
+
+#endif // #include guard
+
diff --git a/libs/local_function/index.html b/libs/local_function/index.html
new file mode 100644
index 000000000..e55456a36
--- /dev/null
+++ b/libs/local_function/index.html
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="refresh" content="0; URL=doc/html/index.html">
+ </head>
+ <body>
+ Automatic redirection failed, click this
+ <a href="doc/html/index.html">link</a> &nbsp;<hr>
+ <p>© Copyright Lorenzo Caminiti, 2009-2012</p>
+ <p>Distributed under the Boost Software License, Version 1.0 (see
+ accompanying file <a href="../../LICENSE_1_0.txt">
+ LICENSE_1_0.txt</a> or a copy at
+ <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p>
+ </body>
+</html>
diff --git a/libs/local_function/test/Jamfile.v2 b/libs/local_function/test/Jamfile.v2
new file mode 100644
index 000000000..a12f5c340
--- /dev/null
+++ b/libs/local_function/test/Jamfile.v2
@@ -0,0 +1,51 @@
+
+# Copyright (C) 2009-2012 Lorenzo Caminiti
+# Distributed under the Boost Software License, Version 1.0
+# (see accompanying file LICENSE_1_0.txt or a copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+# Home at http://www.boost.org/libs/local_function
+
+import testing ;
+
+# Sun does not automatically detect type-of emulation mode (force it).
+project : requirements <toolset>sun:<define>BOOST_TYPEOF_EMULATION ;
+
+rule vaseq ( command target )
+{
+ $(command) $(target).cpp ;
+ $(command) $(target)_seq.cpp ;
+ $(command) $(target)_seq_nova.cpp ;
+}
+
+vaseq run add ;
+vaseq run add_classifiers ;
+vaseq run add_default ;
+vaseq run add_except ;
+vaseq run add_inline ;
+vaseq run add_params_only ;
+vaseq run add_template ;
+vaseq run add_this ;
+vaseq run add_typed ;
+vaseq run add_with_default ;
+vaseq run all_decl ;
+vaseq run factorial ;
+vaseq run goto ;
+vaseq compile-fail goto_error ;
+vaseq run macro_commas ;
+vaseq run nesting ;
+vaseq run operator ;
+vaseq compile-fail operator_error ;
+vaseq run overload ;
+vaseq run return_assign ;
+vaseq run return_derivative ;
+vaseq run return_inc ;
+vaseq run return_setget ;
+vaseq run return_this ;
+vaseq run same_line ;
+vaseq run transform ;
+vaseq run typeof ;
+vaseq run typeof_template ;
+
+run ten_void.cpp ;
+run ten_void_nova.cpp ;
+
diff --git a/libs/local_function/test/add.cpp b/libs/local_function/test/add.cpp
new file mode 100644
index 000000000..4b8ca3f1b
--- /dev/null
+++ b/libs/local_function/test/add.cpp
@@ -0,0 +1,35 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+
+//[add
+int main(void) { // Some local scope.
+ int sum = 0, factor = 10; // Variables in scope to bind.
+
+ void BOOST_LOCAL_FUNCTION(const bind factor, bind& sum, int num) {
+ sum += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ add(1); // Call the local function.
+ int nums[] = {2, 3};
+ std::for_each(nums, nums + 2, add); // Pass it to an algorithm.
+
+ BOOST_TEST(sum == 60); // Assert final summation value.
+ return boost::report_errors();
+}
+//]
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/add_classifiers.cpp b/libs/local_function/test/add_classifiers.cpp
new file mode 100644
index 000000000..7dcf2dc04
--- /dev/null
+++ b/libs/local_function/test/add_classifiers.cpp
@@ -0,0 +1,30 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#if !defined(BOOST_NO_CXX11_AUTO_DECLARATIONS)
+# error "auto-declarations not allowed (using `auto` as storage classifier)"
+#elif defined(BOOST_NO_CXX11_VARIADIC_MACROS)
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main(void) {
+ //[add_classifiers
+ int BOOST_LOCAL_FUNCTION(auto int x, register int y) { // Classifiers.
+ return x + y;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+ //]
+
+ BOOST_TEST(add(1, 2) == 3);
+ return boost::report_errors();
+}
+
+#endif // AUTO_DECLARATIONS && VARIADIC_MACROS
+
diff --git a/libs/local_function/test/add_classifiers_seq.cpp b/libs/local_function/test/add_classifiers_seq.cpp
new file mode 100644
index 000000000..0499f875c
--- /dev/null
+++ b/libs/local_function/test/add_classifiers_seq.cpp
@@ -0,0 +1,26 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifndef BOOST_NO_CXX11_AUTO_DECLARATIONS
+# error "auto-declarations not allowed (using `auto` as storage classifier)"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main(void) {
+ int BOOST_LOCAL_FUNCTION( (auto int x) (register int y) ) {
+ return x + y;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ BOOST_TEST(add(1, 2) == 3);
+ return boost::report_errors();
+}
+
+#endif // AUTO_DECLARATIONS
+
diff --git a/libs/local_function/test/add_classifiers_seq_nova.cpp b/libs/local_function/test/add_classifiers_seq_nova.cpp
new file mode 100644
index 000000000..346258468
--- /dev/null
+++ b/libs/local_function/test/add_classifiers_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "add_classifiers_seq.cpp"
+
diff --git a/libs/local_function/test/add_default.cpp b/libs/local_function/test/add_default.cpp
new file mode 100644
index 000000000..86c4e115a
--- /dev/null
+++ b/libs/local_function/test/add_default.cpp
@@ -0,0 +1,28 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main(void) {
+ //[add_default
+ int BOOST_LOCAL_FUNCTION(int x, int y, default 2) { // Default parameter.
+ return x + y;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ BOOST_TEST(add(1) == 3);
+ //]
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/add_default_seq.cpp b/libs/local_function/test/add_default_seq.cpp
new file mode 100644
index 000000000..8130a90d5
--- /dev/null
+++ b/libs/local_function/test/add_default_seq.cpp
@@ -0,0 +1,19 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main(void) {
+ int BOOST_LOCAL_FUNCTION( (int x) (int y)(default 2) ) {
+ return x + y;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ BOOST_TEST(add(1) == 3);
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/test/add_default_seq_nova.cpp b/libs/local_function/test/add_default_seq_nova.cpp
new file mode 100644
index 000000000..92e4ea776
--- /dev/null
+++ b/libs/local_function/test/add_default_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "add_default_seq.cpp"
+
diff --git a/libs/local_function/test/add_except.cpp b/libs/local_function/test/add_except.cpp
new file mode 100644
index 000000000..c3a148851
--- /dev/null
+++ b/libs/local_function/test/add_except.cpp
@@ -0,0 +1,34 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main(void) {
+ //[add_except
+ double sum = 0.0;
+ int factor = 10;
+
+ void BOOST_LOCAL_FUNCTION(const bind factor, bind& sum,
+ double num) throw() { // Throw nothing.
+ sum += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ add(100);
+ //]
+
+ BOOST_TEST(sum == 1000);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/add_except_seq.cpp b/libs/local_function/test/add_except_seq.cpp
new file mode 100644
index 000000000..be1d18605
--- /dev/null
+++ b/libs/local_function/test/add_except_seq.cpp
@@ -0,0 +1,25 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main(void) {
+ double sum = 0.0;
+ int factor = 10;
+
+ void BOOST_LOCAL_FUNCTION( (const bind factor) (bind& sum)
+ (double num) ) throw() {
+ sum += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ add(100);
+
+ BOOST_TEST(sum == 1000);
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/test/add_except_seq_nova.cpp b/libs/local_function/test/add_except_seq_nova.cpp
new file mode 100644
index 000000000..44f53a29b
--- /dev/null
+++ b/libs/local_function/test/add_except_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "add_except_seq.cpp"
+
diff --git a/libs/local_function/test/add_inline.cpp b/libs/local_function/test/add_inline.cpp
new file mode 100644
index 000000000..4d3afe5c7
--- /dev/null
+++ b/libs/local_function/test/add_inline.cpp
@@ -0,0 +1,37 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <vector>
+#include <algorithm>
+
+int main(void) {
+ //[add_inline
+ int sum = 0, factor = 10;
+
+ void BOOST_LOCAL_FUNCTION(const bind factor, bind& sum, int num) {
+ sum += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME(inline add) // Inlining.
+
+ std::vector<int> v(100);
+ std::fill(v.begin(), v.end(), 1);
+
+ for(size_t i = 0; i < v.size(); ++i) add(v[i]); // Cannot use for_each.
+ //]
+
+ BOOST_TEST(sum == 1000);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/add_inline_seq.cpp b/libs/local_function/test/add_inline_seq.cpp
new file mode 100644
index 000000000..780262152
--- /dev/null
+++ b/libs/local_function/test/add_inline_seq.cpp
@@ -0,0 +1,28 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <vector>
+#include <algorithm>
+
+int main(void) {
+ int sum = 0, factor = 10;
+
+ void BOOST_LOCAL_FUNCTION( (const bind factor) (bind& sum) (int num) ) {
+ sum += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME(inline add)
+
+ std::vector<int> v(100);
+ std::fill(v.begin(), v.end(), 1);
+
+ for(size_t i = 0; i < v.size(); ++i) add(v[i]);
+
+ BOOST_TEST(sum == 1000);
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/test/add_inline_seq_nova.cpp b/libs/local_function/test/add_inline_seq_nova.cpp
new file mode 100644
index 000000000..e040ad6d1
--- /dev/null
+++ b/libs/local_function/test/add_inline_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "add_inline_seq.cpp"
+
diff --git a/libs/local_function/test/add_params_only.cpp b/libs/local_function/test/add_params_only.cpp
new file mode 100644
index 000000000..3b9b93d99
--- /dev/null
+++ b/libs/local_function/test/add_params_only.cpp
@@ -0,0 +1,28 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main(void) {
+ //[add_params_only
+ int BOOST_LOCAL_FUNCTION(int x, int y) { // Local function.
+ return x + y;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ BOOST_TEST(add(1, 2) == 3); // Local function call.
+ //]
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/add_params_only_seq.cpp b/libs/local_function/test/add_params_only_seq.cpp
new file mode 100644
index 000000000..565d5ff90
--- /dev/null
+++ b/libs/local_function/test/add_params_only_seq.cpp
@@ -0,0 +1,19 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main(void) {
+ int BOOST_LOCAL_FUNCTION( (int x) (int y) ) {
+ return x + y;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ BOOST_TEST(add(1, 2) == 3);
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/test/add_params_only_seq_nova.cpp b/libs/local_function/test/add_params_only_seq_nova.cpp
new file mode 100644
index 000000000..7123aae8a
--- /dev/null
+++ b/libs/local_function/test/add_params_only_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "add_params_only_seq.cpp"
+
diff --git a/libs/local_function/test/add_seq.cpp b/libs/local_function/test/add_seq.cpp
new file mode 100644
index 000000000..d04819b2c
--- /dev/null
+++ b/libs/local_function/test/add_seq.cpp
@@ -0,0 +1,28 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+
+//[add_seq
+int main(void) {
+ int sum = 0, factor = 10;
+
+ void BOOST_LOCAL_FUNCTION( (const bind factor) (bind& sum) (int num) ) {
+ sum += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ add(1);
+ int nums[] = {2, 3};
+ std::for_each(nums, nums + 2, add);
+
+ BOOST_TEST(sum == 60);
+ return boost::report_errors();
+}
+//]
+
diff --git a/libs/local_function/test/add_seq_nova.cpp b/libs/local_function/test/add_seq_nova.cpp
new file mode 100644
index 000000000..ce0c279f5
--- /dev/null
+++ b/libs/local_function/test/add_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "add_seq.cpp"
+
diff --git a/libs/local_function/test/add_template.cpp b/libs/local_function/test/add_template.cpp
new file mode 100644
index 000000000..aa382673b
--- /dev/null
+++ b/libs/local_function/test/add_template.cpp
@@ -0,0 +1,41 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+
+//[add_template
+template<typename T>
+T total(const T& x, const T& y, const T& z) {
+ T sum = T(), factor = 10;
+
+ // Must use the `..._TPL` macros within templates.
+ T BOOST_LOCAL_FUNCTION_TPL(const bind factor, bind& sum, T num) {
+ return sum += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME_TPL(add)
+
+ add(x);
+ T nums[2]; nums[0] = y; nums[1] = z;
+ std::for_each(nums, nums + 2, add);
+
+ return sum;
+}
+//]
+
+int main(void) {
+ BOOST_TEST(total(1, 2, 3) == 60);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/add_template_seq.cpp b/libs/local_function/test/add_template_seq.cpp
new file mode 100644
index 000000000..3c0ea7155
--- /dev/null
+++ b/libs/local_function/test/add_template_seq.cpp
@@ -0,0 +1,31 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+
+template<typename T>
+T total(const T& x, const T& y, const T& z) {
+ T sum = T(), factor = 10;
+
+ T BOOST_LOCAL_FUNCTION_TPL( (const bind factor) (bind& sum) (T num) ) {
+ return sum += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME_TPL(add)
+
+ add(x);
+ T nums[2]; nums[0] = y; nums[1] = z;
+ std::for_each(nums, nums + 2, add);
+
+ return sum;
+}
+
+int main(void) {
+ BOOST_TEST(total(1, 2, 3) == 60);
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/test/add_template_seq_nova.cpp b/libs/local_function/test/add_template_seq_nova.cpp
new file mode 100644
index 000000000..9c02384b1
--- /dev/null
+++ b/libs/local_function/test/add_template_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "add_template_seq.cpp"
+
diff --git a/libs/local_function/test/add_this.cpp b/libs/local_function/test/add_this.cpp
new file mode 100644
index 000000000..f42404367
--- /dev/null
+++ b/libs/local_function/test/add_this.cpp
@@ -0,0 +1,51 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+#include <vector>
+#include <algorithm>
+
+struct adder;
+BOOST_TYPEOF_REGISTER_TYPE(adder) // Register before `bind this_` below.
+
+//[add_this
+struct adder {
+ adder() : sum_(0) {}
+
+ int sum(const std::vector<int>& nums, const int factor = 10) {
+
+ void BOOST_LOCAL_FUNCTION(const bind factor, bind this_, int num) {
+ this_->sum_ += factor * num; // Use `this_` instead of `this`.
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ std::for_each(nums.begin(), nums.end(), add);
+ return sum_;
+ }
+
+private:
+ int sum_;
+};
+//]
+
+int main(void) {
+ std::vector<int> v(3);
+ v[0] = 1; v[1] = 2; v[2] = 3;
+
+ BOOST_TEST(adder().sum(v) == 60);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/add_this_seq.cpp b/libs/local_function/test/add_this_seq.cpp
new file mode 100644
index 000000000..9957122e7
--- /dev/null
+++ b/libs/local_function/test/add_this_seq.cpp
@@ -0,0 +1,43 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+#include <vector>
+#include <algorithm>
+
+struct adder;
+BOOST_TYPEOF_REGISTER_TYPE(adder) // Register before `bind this_` below.
+
+struct adder {
+ adder() : sum_(0) {}
+
+ int sum(const std::vector<int>& nums, const int factor = 10) {
+
+ void BOOST_LOCAL_FUNCTION( (const bind factor) (bind this_)
+ (int num) ) {
+ this_->sum_ += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ std::for_each(nums.begin(), nums.end(), add);
+ return sum_;
+ }
+
+private:
+ int sum_;
+};
+
+int main(void) {
+ std::vector<int> v(3);
+ v[0] = 1; v[1] = 2; v[2] = 3;
+
+ BOOST_TEST(adder().sum(v) == 60);
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/test/add_this_seq_nova.cpp b/libs/local_function/test/add_this_seq_nova.cpp
new file mode 100644
index 000000000..e01573908
--- /dev/null
+++ b/libs/local_function/test/add_this_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "add_this_seq.cpp"
+
diff --git a/libs/local_function/test/add_typed.cpp b/libs/local_function/test/add_typed.cpp
new file mode 100644
index 000000000..6912a334b
--- /dev/null
+++ b/libs/local_function/test/add_typed.cpp
@@ -0,0 +1,47 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <vector>
+#include <algorithm>
+
+//[add_typed
+struct adder {
+ adder(void) : sum_(0) {}
+
+ int sum(const std::vector<int>& nums, const int& factor = 10) {
+ // Explicitly specify bound variable and return types (no type-of).
+ BOOST_LOCAL_FUNCTION(const bind(const int&) factor,
+ bind(adder*) this_, int num, return int) {
+ return this_->sum_ += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ std::for_each(nums.begin(), nums.end(), add);
+ return sum_;
+ }
+
+private:
+ int sum_;
+};
+//]
+
+int main(void) {
+ std::vector<int> v(3);
+ v[0] = 1; v[1] = 2; v[2] = 3;
+
+ BOOST_TEST(adder().sum(v) == 60);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/add_typed_seq.cpp b/libs/local_function/test/add_typed_seq.cpp
new file mode 100644
index 000000000..e62ff505c
--- /dev/null
+++ b/libs/local_function/test/add_typed_seq.cpp
@@ -0,0 +1,37 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <vector>
+#include <algorithm>
+
+struct adder {
+ adder(void) : sum_(0) {}
+
+ int sum(const std::vector<int>& nums, const int& factor = 10) {
+ BOOST_LOCAL_FUNCTION( (const bind(const int&) factor)
+ (bind(adder*) this_) (int num) (return int) ) {
+ return this_->sum_ += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ std::for_each(nums.begin(), nums.end(), add);
+ return sum_;
+ }
+
+private:
+ int sum_;
+};
+
+int main(void) {
+ std::vector<int> v(3);
+ v[0] = 1; v[1] = 2; v[2] = 3;
+
+ BOOST_TEST(adder().sum(v) == 60);
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/test/add_typed_seq_nova.cpp b/libs/local_function/test/add_typed_seq_nova.cpp
new file mode 100644
index 000000000..0cdb35615
--- /dev/null
+++ b/libs/local_function/test/add_typed_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "add_typed_seq.cpp"
+
diff --git a/libs/local_function/test/add_with_default.cpp b/libs/local_function/test/add_with_default.cpp
new file mode 100644
index 000000000..f31cb1c63
--- /dev/null
+++ b/libs/local_function/test/add_with_default.cpp
@@ -0,0 +1,32 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+//[add_with_default_macro
+#define WITH_DEFAULT , default
+//]
+
+int main(void) {
+ //[add_with_default
+ int BOOST_LOCAL_FUNCTION(int x, int y WITH_DEFAULT 2) { // Default.
+ return x + y;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ BOOST_TEST(add(1) == 3);
+ //]
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/add_with_default_seq.cpp b/libs/local_function/test/add_with_default_seq.cpp
new file mode 100644
index 000000000..1513af021
--- /dev/null
+++ b/libs/local_function/test/add_with_default_seq.cpp
@@ -0,0 +1,21 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#define WITH_DEFAULT )(default
+
+int main(void) {
+ int BOOST_LOCAL_FUNCTION( (int x) (int y WITH_DEFAULT 2) ) {
+ return x + y;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ BOOST_TEST(add(1) == 3);
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/test/add_with_default_seq_nova.cpp b/libs/local_function/test/add_with_default_seq_nova.cpp
new file mode 100644
index 000000000..d7149cc78
--- /dev/null
+++ b/libs/local_function/test/add_with_default_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "add_with_default_seq.cpp"
+
diff --git a/libs/local_function/test/addable.hpp b/libs/local_function/test/addable.hpp
new file mode 100644
index 000000000..3b13ab288
--- /dev/null
+++ b/libs/local_function/test/addable.hpp
@@ -0,0 +1,26 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#ifndef ADDABLE_HPP_
+#define ADDABLE_HPP_
+
+#include <boost/concept_check.hpp>
+
+template<typename T>
+struct Addable { // User-defined concept.
+ BOOST_CONCEPT_USAGE(Addable) {
+ return_type(x + y); // Check addition `T operator+(T x, T y)`.
+ }
+
+private:
+ void return_type(T) {} // Implementation (required for some linkers).
+ static T const& x;
+ static T const& y;
+};
+
+#endif // #include guard
+
diff --git a/libs/local_function/test/all_decl.cpp b/libs/local_function/test/all_decl.cpp
new file mode 100644
index 000000000..a9a63db1c
--- /dev/null
+++ b/libs/local_function/test/all_decl.cpp
@@ -0,0 +1,177 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+
+struct s;
+BOOST_TYPEOF_REGISTER_TYPE(s) // Register before binding `this_` below.
+
+// Compile all local function declaration combinations.
+struct s {
+ void f(double p = 1.23, double q = -1.23) {
+ { // Only params.
+ void BOOST_LOCAL_FUNCTION(int x, int y, default 0) {
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l(1);
+ }
+ { // Only const binds.
+ int a, b;
+
+ const int& BOOST_LOCAL_FUNCTION(const bind a,
+ const bind& b, const bind& p, const bind q) {
+ return b;
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l();
+
+ const s& BOOST_LOCAL_FUNCTION(const bind this_) {
+ return *this_;
+ } BOOST_LOCAL_FUNCTION_NAME(t)
+ t();
+
+ const int BOOST_LOCAL_FUNCTION(const bind a,
+ const bind& b, const bind& p, const bind q,
+ const bind this_) {
+ return a;
+ } BOOST_LOCAL_FUNCTION_NAME(lt)
+ lt();
+ }
+ { // Only plain binds.
+ int c, d;
+
+ int& BOOST_LOCAL_FUNCTION(bind c, bind& d,
+ bind& p, bind& q) {
+ return d;
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l();
+
+ s& BOOST_LOCAL_FUNCTION(bind this_) {
+ return *this_;
+ } BOOST_LOCAL_FUNCTION_NAME(t)
+ t();
+
+ int BOOST_LOCAL_FUNCTION(bind c, bind& d,
+ bind& p, bind& q, bind this_) {
+ return c;
+ } BOOST_LOCAL_FUNCTION_NAME(lt)
+ lt();
+ }
+
+ { // Both params and const binds.
+ int a, b;
+
+ void BOOST_LOCAL_FUNCTION(const bind a, const bind& b,
+ const bind& p, const bind q,
+ int x, int y, default 0) {
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l(1);
+
+ void BOOST_LOCAL_FUNCTION(const bind this_,
+ int x, int y, default 0) {
+ } BOOST_LOCAL_FUNCTION_NAME(t)
+ t(1);
+
+ void BOOST_LOCAL_FUNCTION(const bind a, const bind this_,
+ const bind& b, const bind& p, const bind q,
+ int x, int y, default 0) {
+ } BOOST_LOCAL_FUNCTION_NAME(lt)
+ lt(1);
+ }
+ { // Both params and plain binds.
+ int c, d;
+
+ void BOOST_LOCAL_FUNCTION(bind c, bind& d, bind& p, bind q,
+ int x, int y, default 0) {
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l(1);
+
+ void BOOST_LOCAL_FUNCTION(bind this_,
+ int x, int y, default 0) {
+ } BOOST_LOCAL_FUNCTION_NAME(t)
+ t(1);
+
+ void BOOST_LOCAL_FUNCTION(bind c, bind& d,
+ bind& p, bind this_, bind q,
+ int x, int y, default 0) {
+ } BOOST_LOCAL_FUNCTION_NAME(lt)
+ lt(1);
+ }
+ { // Both const and plain binds.
+ int a, b, c, d;
+
+ void BOOST_LOCAL_FUNCTION(const bind a, const bind& b,
+ const bind p, bind c, bind& d, bind q) {
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l();
+
+ void BOOST_LOCAL_FUNCTION(const bind this_,
+ bind c, bind& d, bind q) {
+ } BOOST_LOCAL_FUNCTION_NAME(ct)
+ ct();
+ void BOOST_LOCAL_FUNCTION(const bind this_,
+ const bind a, const bind& b, const bind p,
+ bind c, bind& d, bind q) {
+ } BOOST_LOCAL_FUNCTION_NAME(lct)
+ lct();
+
+ void BOOST_LOCAL_FUNCTION(const bind a, const bind& b,
+ const bind p, bind this_) {
+ } BOOST_LOCAL_FUNCTION_NAME(pt)
+ pt();
+ void BOOST_LOCAL_FUNCTION(const bind a, const bind& b,
+ const bind p, bind c, bind this_, bind& d, bind q) {
+ } BOOST_LOCAL_FUNCTION_NAME(lpt)
+ lpt();
+ }
+
+ { // All params, const binds, and plain binds.
+ int a, b, c, d;
+
+ void BOOST_LOCAL_FUNCTION(
+ const bind a, const bind& b, const bind& p,
+ bind c, bind& d, bind& q, int x, int y, default 0) {
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l(1);
+
+ void BOOST_LOCAL_FUNCTION(const bind this_,
+ bind c, bind& d, bind& q,
+ int x, int y, default 0) {
+ } BOOST_LOCAL_FUNCTION_NAME(ct)
+ ct(1);
+ void BOOST_LOCAL_FUNCTION(
+ const bind a, const bind& b, const bind& p,
+ bind this_, int x, int y, default 0) {
+ } BOOST_LOCAL_FUNCTION_NAME(pt)
+ pt(1);
+
+ void BOOST_LOCAL_FUNCTION(const bind a, const bind this_,
+ const bind& b, const bind& p, bind c, bind& d,
+ bind& q, int x, int y, default 0) {
+ } BOOST_LOCAL_FUNCTION_NAME(lct)
+ lct(1);
+ void BOOST_LOCAL_FUNCTION(const bind a, const bind& b,
+ const bind& p, bind c, bind& d, bind this_, bind& q,
+ int x, int y, default 0) {
+ } BOOST_LOCAL_FUNCTION_NAME(lpt)
+ lpt(1);
+ }
+ }
+};
+
+int main(void) {
+ s().f();
+ return 0;
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/all_decl_seq.cpp b/libs/local_function/test/all_decl_seq.cpp
new file mode 100644
index 000000000..95fb75ede
--- /dev/null
+++ b/libs/local_function/test/all_decl_seq.cpp
@@ -0,0 +1,170 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+
+struct s;
+BOOST_TYPEOF_REGISTER_TYPE(s); // Register before bind `this_` below.
+
+// Compile all local function declaration combinations.
+struct s {
+ void f(double p = 1.23, double q = -1.23) {
+ { // Only params.
+ void BOOST_LOCAL_FUNCTION( (int x) (int y)(default 0) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l(1);
+ }
+ { // Only const binds.
+ int a, b;
+
+ const int& BOOST_LOCAL_FUNCTION( (const bind a)
+ (const bind& b) (const bind& p) (const bind q) ) {
+ return b;
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l();
+
+ const s& BOOST_LOCAL_FUNCTION( (const bind this_) ) {
+ return *this_;
+ } BOOST_LOCAL_FUNCTION_NAME(t)
+ t();
+
+ const int BOOST_LOCAL_FUNCTION( (const bind a)
+ (const bind& b) (const bind& p) (const bind q)
+ (const bind this_) ) {
+ return a;
+ } BOOST_LOCAL_FUNCTION_NAME(lt)
+ lt();
+ }
+ { // Only plain binds.
+ int c, d;
+
+ int& BOOST_LOCAL_FUNCTION( (bind c) (bind& d)
+ (bind& p) (bind& q) ) {
+ return d;
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l();
+
+ s& BOOST_LOCAL_FUNCTION( (bind this_) ) {
+ return *this_;
+ } BOOST_LOCAL_FUNCTION_NAME(t)
+ t();
+
+ int BOOST_LOCAL_FUNCTION( (bind c) (bind& d)
+ (bind& p) (bind& q) (bind this_) ) {
+ return c;
+ } BOOST_LOCAL_FUNCTION_NAME(lt)
+ lt();
+ }
+
+ { // Both params and const binds.
+ int a, b;
+
+ void BOOST_LOCAL_FUNCTION( (const bind a) (const bind& b)
+ (const bind& p) (const bind q)
+ (int x) (int y)(default 0) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l(1);
+
+ void BOOST_LOCAL_FUNCTION( (const bind this_)
+ (int x) (int y)(default 0) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(t)
+ t(1);
+
+ void BOOST_LOCAL_FUNCTION( (const bind a) (const bind this_)
+ (const bind& b) (const bind& p) (const bind q)
+ (int x) (int y)(default 0) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(lt)
+ lt(1);
+ }
+ { // Both params and plain binds.
+ int c, d;
+
+ void BOOST_LOCAL_FUNCTION( (bind c) (bind& d) (bind& p) (bind q)
+ (int x) (int y)(default 0) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l(1);
+
+ void BOOST_LOCAL_FUNCTION( (bind this_)
+ (int x) (int y)(default 0) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(t)
+ t(1);
+
+ void BOOST_LOCAL_FUNCTION( (bind c) (bind& d)
+ (bind& p) (bind this_) (bind q)
+ (int x) (int y)(default 0) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(lt)
+ lt(1);
+ }
+ { // Both const and plain binds.
+ int a, b, c, d;
+
+ void BOOST_LOCAL_FUNCTION( (const bind a) (const bind& b)
+ (const bind p) (bind c) (bind& d) (bind q) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l();
+
+ void BOOST_LOCAL_FUNCTION( (const bind this_)
+ (bind c) (bind& d) (bind q) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(ct)
+ ct();
+ void BOOST_LOCAL_FUNCTION( (const bind this_)
+ (const bind a) (const bind& b) (const bind p)
+ (bind c) (bind& d) (bind q) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(lct)
+ lct();
+
+ void BOOST_LOCAL_FUNCTION( (const bind a) (const bind& b)
+ (const bind p) (bind this_) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(pt)
+ pt();
+ void BOOST_LOCAL_FUNCTION( (const bind a) (const bind& b)
+ (const bind p) (bind c) (bind this_) (bind& d) (bind q) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(lpt)
+ lpt();
+ }
+
+ { // All params, const binds, and plain binds.
+ int a, b, c, d;
+
+ void BOOST_LOCAL_FUNCTION(
+ (const bind a) (const bind& b) (const bind& p)
+ (bind c) (bind& d) (bind& q) (int x) (int y)(default 0) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(l)
+ l(1);
+
+ void BOOST_LOCAL_FUNCTION( (const bind this_)
+ (bind c) (bind& d) (bind& q)
+ (int x) (int y)(default 0) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(ct)
+ ct(1);
+ void BOOST_LOCAL_FUNCTION(
+ (const bind a) (const bind& b) (const bind& p)
+ (bind this_) (int x) (int y)(default 0) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(pt)
+ pt(1);
+
+ void BOOST_LOCAL_FUNCTION( (const bind a) (const bind this_)
+ (const bind& b) (const bind& p) (bind c) (bind& d)
+ (bind& q) (int x) (int y)(default 0) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(lct)
+ lct(1);
+ void BOOST_LOCAL_FUNCTION( (const bind a) (const bind& b)
+ (const bind& p) (bind c) (bind& d) (bind this_) (bind& q)
+ (int x) (int y)(default 0) ) {
+ } BOOST_LOCAL_FUNCTION_NAME(lpt)
+ lpt(1);
+ }
+ }
+};
+
+int main(void) {
+ s().f();
+ return 0;
+}
+
diff --git a/libs/local_function/test/all_decl_seq_nova.cpp b/libs/local_function/test/all_decl_seq_nova.cpp
new file mode 100644
index 000000000..8333b2857
--- /dev/null
+++ b/libs/local_function/test/all_decl_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "all_decl_seq.cpp"
+
diff --git a/libs/local_function/test/factorial.cpp b/libs/local_function/test/factorial.cpp
new file mode 100644
index 000000000..7260de23a
--- /dev/null
+++ b/libs/local_function/test/factorial.cpp
@@ -0,0 +1,57 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+#include <vector>
+
+struct calculator;
+BOOST_TYPEOF_REGISTER_TYPE(calculator) // Register before `bind this_` below.
+
+//[factorial
+struct calculator {
+ std::vector<int> results;
+
+ void factorials(const std::vector<int>& nums) {
+ int BOOST_LOCAL_FUNCTION(bind this_, int num,
+ bool recursion, default false) {
+ int result = 0;
+
+ if(num <= 0) result = 1;
+ else result = num * factorial(num - 1, true); // Recursive call.
+
+ if(!recursion) this_->results.push_back(result);
+ return result;
+ } BOOST_LOCAL_FUNCTION_NAME(recursive factorial) // Recursive.
+
+ std::for_each(nums.begin(), nums.end(), factorial);
+ }
+};
+//]
+
+int main(void) {
+ std::vector<int> v(3);
+ v[0] = 1; v[1] = 3; v[2] = 4;
+
+ calculator calc;
+ calc.factorials(v);
+ BOOST_TEST(calc.results[0] == 1);
+ BOOST_TEST(calc.results[1] == 6);
+ BOOST_TEST(calc.results[2] == 24);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/factorial_seq.cpp b/libs/local_function/test/factorial_seq.cpp
new file mode 100644
index 000000000..e7c242c27
--- /dev/null
+++ b/libs/local_function/test/factorial_seq.cpp
@@ -0,0 +1,48 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+#include <vector>
+
+struct calculator;
+BOOST_TYPEOF_REGISTER_TYPE(calculator) // Register before `bind this_` below.
+
+struct calculator {
+ std::vector<int> results;
+
+ void factorials(const std::vector<int>& nums) {
+ int BOOST_LOCAL_FUNCTION( (bind this_) (int num)
+ (bool recursion)(default false) ) {
+ int result = 0;
+
+ if(num <= 0) result = 1;
+ else result = num * factorial(num - 1, true);
+
+ if(!recursion) this_->results.push_back(result);
+ return result;
+ } BOOST_LOCAL_FUNCTION_NAME(recursive factorial)
+
+ std::for_each(nums.begin(), nums.end(), factorial);
+ }
+};
+
+int main(void) {
+ std::vector<int> v(3);
+ v[0] = 1; v[1] = 3; v[2] = 4;
+
+ calculator calc;
+ calc.factorials(v);
+ BOOST_TEST(calc.results[0] == 1);
+ BOOST_TEST(calc.results[1] == 6);
+ BOOST_TEST(calc.results[2] == 24);
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/test/factorial_seq_nova.cpp b/libs/local_function/test/factorial_seq_nova.cpp
new file mode 100644
index 000000000..b9376125a
--- /dev/null
+++ b/libs/local_function/test/factorial_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "factorial_seq.cpp"
+
diff --git a/libs/local_function/test/goto.cpp b/libs/local_function/test/goto.cpp
new file mode 100644
index 000000000..a6dda7512
--- /dev/null
+++ b/libs/local_function/test/goto.cpp
@@ -0,0 +1,34 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+
+//[goto
+int error(int x, int y) {
+ int BOOST_LOCAL_FUNCTION(int z) {
+ if(z > 0) goto success; // OK: Can jump within local function.
+ return -1;
+ success:
+ return 0;
+ } BOOST_LOCAL_FUNCTION_NAME(validate)
+
+ return validate(x + y);
+}
+//]
+
+int main(void) {
+ error(1, 2);
+ return 0;
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/goto_error.cpp b/libs/local_function/test/goto_error.cpp
new file mode 100644
index 000000000..3ed397194
--- /dev/null
+++ b/libs/local_function/test/goto_error.cpp
@@ -0,0 +1,36 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+
+//[goto_error
+int error(int x, int y) {
+ int BOOST_LOCAL_FUNCTION(int z) {
+ if(z <= 0) goto failure; // Error: Cannot jump to enclosing scope.
+ else goto success; // OK: Can jump within local function.
+ success:
+ return 0;
+ } BOOST_LOCAL_FUNCTION_NAME(validate)
+
+ return validate(x + y);
+failure:
+ return -1;
+}
+//]
+
+int main(void) {
+ error(1, 2);
+ return 0;
+}
+
+#endif
+
diff --git a/libs/local_function/test/goto_error_seq.cpp b/libs/local_function/test/goto_error_seq.cpp
new file mode 100644
index 000000000..178ac4372
--- /dev/null
+++ b/libs/local_function/test/goto_error_seq.cpp
@@ -0,0 +1,27 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+
+int error(int x, int y) {
+ int BOOST_LOCAL_FUNCTION( (int z) ) {
+ if(z <= 0) goto failure;
+ else goto success;
+ success:
+ return 0;
+ } BOOST_LOCAL_FUNCTION_NAME(validate)
+
+ return validate(x + y);
+failure:
+ return -1;
+}
+
+int main(void) {
+ error(1, 2);
+ return 0;
+}
+
diff --git a/libs/local_function/test/goto_error_seq_nova.cpp b/libs/local_function/test/goto_error_seq_nova.cpp
new file mode 100644
index 000000000..6433add5c
--- /dev/null
+++ b/libs/local_function/test/goto_error_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "goto_error_seq.cpp"
+
diff --git a/libs/local_function/test/goto_seq.cpp b/libs/local_function/test/goto_seq.cpp
new file mode 100644
index 000000000..5acb5b46d
--- /dev/null
+++ b/libs/local_function/test/goto_seq.cpp
@@ -0,0 +1,25 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+
+int error(int x, int y) {
+ int BOOST_LOCAL_FUNCTION( (int z) ) {
+ if(z > 0) goto success;
+ return -1;
+ success:
+ return 0;
+ } BOOST_LOCAL_FUNCTION_NAME(validate)
+
+ return validate(x + y);
+}
+
+int main(void) {
+ error(1, 2);
+ return 0;
+}
+
diff --git a/libs/local_function/test/goto_seq_nova.cpp b/libs/local_function/test/goto_seq_nova.cpp
new file mode 100644
index 000000000..edec9f283
--- /dev/null
+++ b/libs/local_function/test/goto_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "goto_seq.cpp"
+
diff --git a/libs/local_function/test/macro_commas.cpp b/libs/local_function/test/macro_commas.cpp
new file mode 100644
index 000000000..3905782f6
--- /dev/null
+++ b/libs/local_function/test/macro_commas.cpp
@@ -0,0 +1,52 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/utility/identity_type.hpp>
+#include <boost/typeof/std/string.hpp> // Type-of registrations
+#include <boost/typeof/std/map.hpp> // needed for `NAME` macro.
+#include <map>
+#include <string>
+
+std::string cat(const std::string& x, const std::string& y) { return x + y; }
+
+template<typename V, typename K>
+struct key_sizeof {
+ static int const value;
+};
+
+template<typename V, typename K>
+int const key_sizeof<V, K>::value = sizeof(K);
+
+typedef int sign_t;
+
+int main(void) {
+ //[macro_commas
+ void BOOST_LOCAL_FUNCTION(
+ BOOST_IDENTITY_TYPE((const std::map<std::string, size_t>&)) m,
+ BOOST_IDENTITY_TYPE((::sign_t)) sign,
+ const size_t& factor,
+ default (key_sizeof<std::string, size_t>::value),
+ const std::string& separator, default cat(":", " ")
+ ) {
+ // Do something...
+ } BOOST_LOCAL_FUNCTION_NAME(f)
+ //]
+
+ std::map<std::string, size_t> m;
+ ::sign_t sign = -1;
+ f(m, sign);
+ return 0;
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/macro_commas_seq.cpp b/libs/local_function/test/macro_commas_seq.cpp
new file mode 100644
index 000000000..f2e0f49af
--- /dev/null
+++ b/libs/local_function/test/macro_commas_seq.cpp
@@ -0,0 +1,44 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/utility/identity_type.hpp>
+#include <boost/typeof/std/string.hpp> // Type-of registrations
+#include <boost/typeof/std/map.hpp> // needed for `NAME` macro.
+#include <boost/config.hpp>
+#include <map>
+#include <string>
+
+std::string cat(const std::string& x, const std::string& y) { return x + y; }
+
+template<typename V, typename K>
+struct key_sizeof {
+ static int const value;
+};
+
+template<typename V, typename K>
+int const key_sizeof<V, K>::value = sizeof(K);
+
+typedef int sign_t;
+
+int main(void) {
+ void BOOST_LOCAL_FUNCTION(
+ (BOOST_IDENTITY_TYPE((const std::map<std::string, size_t>&)) m)
+ (BOOST_IDENTITY_TYPE((::sign_t)) sign)
+ (const size_t& factor)
+ (default (key_sizeof<std::string, size_t>::value))
+ (const std::string& separator)(default cat(":", " "))
+ ) {
+ // Do something...
+ } BOOST_LOCAL_FUNCTION_NAME(f)
+
+ std::map<std::string, size_t> m;
+ ::sign_t sign = -1;
+ f(m, sign);
+ return 0;
+}
+
diff --git a/libs/local_function/test/macro_commas_seq_nova.cpp b/libs/local_function/test/macro_commas_seq_nova.cpp
new file mode 100644
index 000000000..4252379d6
--- /dev/null
+++ b/libs/local_function/test/macro_commas_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "macro_commas_seq.cpp"
+
diff --git a/libs/local_function/test/nesting.cpp b/libs/local_function/test/nesting.cpp
new file mode 100644
index 000000000..e13ac2692
--- /dev/null
+++ b/libs/local_function/test/nesting.cpp
@@ -0,0 +1,37 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main(void) {
+ //[nesting
+ int x = 0;
+
+ void BOOST_LOCAL_FUNCTION(bind& x) {
+ void BOOST_LOCAL_FUNCTION(bind& x) { // Nested.
+ x++;
+ } BOOST_LOCAL_FUNCTION_NAME(g)
+
+ x--;
+ g(); // Nested local function call.
+ } BOOST_LOCAL_FUNCTION_NAME(f)
+
+ f();
+ //]
+
+ BOOST_TEST(x == 0);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/nesting_seq.cpp b/libs/local_function/test/nesting_seq.cpp
new file mode 100644
index 000000000..6e18558bf
--- /dev/null
+++ b/libs/local_function/test/nesting_seq.cpp
@@ -0,0 +1,28 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main(void) {
+ int x = 0;
+
+ void BOOST_LOCAL_FUNCTION( (bind& x) ) {
+ void BOOST_LOCAL_FUNCTION( (bind& x) ) {
+ x++;
+ } BOOST_LOCAL_FUNCTION_NAME(g)
+
+ x--;
+ g();
+ } BOOST_LOCAL_FUNCTION_NAME(f)
+
+ f();
+
+ BOOST_TEST(x == 0);
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/test/nesting_seq_nova.cpp b/libs/local_function/test/nesting_seq_nova.cpp
new file mode 100644
index 000000000..caeb0720c
--- /dev/null
+++ b/libs/local_function/test/nesting_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "nesting_seq.cpp"
+
diff --git a/libs/local_function/test/nova.hpp b/libs/local_function/test/nova.hpp
new file mode 100644
index 000000000..ceef87eed
--- /dev/null
+++ b/libs/local_function/test/nova.hpp
@@ -0,0 +1,21 @@
+
+// Copyright (C) 2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/scope_exit
+
+#ifndef NOVA_HPP_
+#define NOVA_HPP_
+
+#include <boost/config.hpp>
+
+// WARNING: This file must be included first in each compilation unit.
+
+// Force no variadic macros but avoiding macro redefinition warning/error.
+#ifndef BOOST_NO_CXX11_VARIADIC_MACROS
+# define BOOST_NO_CXX11_VARIADIC_MACROS
+#endif
+
+#endif // #include guard
+
diff --git a/libs/local_function/test/operator.cpp b/libs/local_function/test/operator.cpp
new file mode 100644
index 000000000..c8911c3e4
--- /dev/null
+++ b/libs/local_function/test/operator.cpp
@@ -0,0 +1,38 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+
+//[operator
+struct point {
+ int x;
+ int y;
+};
+BOOST_TYPEOF_REGISTER_TYPE(point) // Register for `NAME` below.
+
+int main(void) {
+ bool BOOST_LOCAL_FUNCTION(const point& p, const point& q) {
+ return p.x == q.x && p.y == q.y;
+ } BOOST_LOCAL_FUNCTION_NAME(equal) // OK: not using `operator==`.
+
+ point a; a.x = 1; a.y = 2;
+ point b = a;
+ BOOST_TEST(equal(a, b));
+ return boost::report_errors();
+}
+//]
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/operator_error.cpp b/libs/local_function/test/operator_error.cpp
new file mode 100644
index 000000000..9fd81f622
--- /dev/null
+++ b/libs/local_function/test/operator_error.cpp
@@ -0,0 +1,38 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+
+struct point {
+ int x;
+ int y;
+};
+BOOST_TYPEOF_REGISTER_TYPE(point) // Register for `NAME` below.
+
+int main(void) {
+ //[operator_error
+ bool BOOST_LOCAL_FUNCTION(const point& p, const point& q) {
+ return p.x == q.x && p.y == q.y;
+ } BOOST_LOCAL_FUNCTION_NAME(operator==) // Error: Cannot use `operator...`.
+ //]
+
+ point a; a.x = 1; a.y = 2;
+ point b = a;
+ BOOST_TEST(a == b);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/operator_error_seq.cpp b/libs/local_function/test/operator_error_seq.cpp
new file mode 100644
index 000000000..08c21f2a1
--- /dev/null
+++ b/libs/local_function/test/operator_error_seq.cpp
@@ -0,0 +1,29 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+
+struct point {
+ int x;
+ int y;
+};
+BOOST_TYPEOF_REGISTER_TYPE(point) // Register for `NAME` below.
+
+int main(void) {
+ bool BOOST_LOCAL_FUNCTION( (const point& p) (const point& q) ) {
+ return p.x == q.x && p.y == q.y;
+ } BOOST_LOCAL_FUNCTION_NAME(operator==)
+
+ point a; a.x = 1; a.y = 2;
+ point b = a;
+ BOOST_TEST(a == b);
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/test/operator_error_seq_nova.cpp b/libs/local_function/test/operator_error_seq_nova.cpp
new file mode 100644
index 000000000..6df7178ab
--- /dev/null
+++ b/libs/local_function/test/operator_error_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "operator_error_seq.cpp"
+
diff --git a/libs/local_function/test/operator_seq.cpp b/libs/local_function/test/operator_seq.cpp
new file mode 100644
index 000000000..d4f70f450
--- /dev/null
+++ b/libs/local_function/test/operator_seq.cpp
@@ -0,0 +1,29 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+
+struct point {
+ int x;
+ int y;
+};
+BOOST_TYPEOF_REGISTER_TYPE(point) // Register for `NAME` below.
+
+int main(void) {
+ bool BOOST_LOCAL_FUNCTION( (const point& p) (const point& q) ) {
+ return p.x == q.x && p.y == q.y;
+ } BOOST_LOCAL_FUNCTION_NAME(equal)
+
+ point a; a.x = 1; a.y = 2;
+ point b = a;
+ BOOST_TEST(equal(a, b));
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/test/operator_seq_nova.cpp b/libs/local_function/test/operator_seq_nova.cpp
new file mode 100644
index 000000000..e6f624682
--- /dev/null
+++ b/libs/local_function/test/operator_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "operator_seq.cpp"
+
diff --git a/libs/local_function/test/overload.cpp b/libs/local_function/test/overload.cpp
new file mode 100644
index 000000000..6a2c1eede
--- /dev/null
+++ b/libs/local_function/test/overload.cpp
@@ -0,0 +1,52 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/functional/overloaded_function.hpp> // For overloading.
+#include <boost/typeof/std/string.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <string>
+
+//[overload_decl
+int add_i(int x, int y) { return x + y; }
+//]
+
+int main(void) {
+ //[overload
+ std::string s = "abc";
+ std::string BOOST_LOCAL_FUNCTION(
+ const bind& s, const std::string& x) {
+ return s + x;
+ } BOOST_LOCAL_FUNCTION_NAME(add_s)
+
+ double d = 1.23;
+ double BOOST_LOCAL_FUNCTION(const bind d, double x, double y, default 0) {
+ return d + x + y;
+ } BOOST_LOCAL_FUNCTION_NAME(add_d)
+
+ boost::overloaded_function<
+ std::string (const std::string&)
+ , double (double)
+ , double (double, double) // Overload giving default param.
+ , int (int, int)
+ > add(add_s, add_d, add_d, add_i); // Overloaded function object.
+
+ BOOST_TEST(add("xyz") == "abcxyz"); // Call `add_s`.
+ BOOST_TEST((4.44 - add(3.21)) <= 0.001); // Call `add_d` (no default).
+ BOOST_TEST((44.44 - add(3.21, 40.0)) <= 0.001); // Call `add_d`.
+ BOOST_TEST(add(1, 2) == 3); // Call `add_i`.
+ //]
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/overload_seq.cpp b/libs/local_function/test/overload_seq.cpp
new file mode 100644
index 000000000..5bb0dab7d
--- /dev/null
+++ b/libs/local_function/test/overload_seq.cpp
@@ -0,0 +1,42 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/functional/overloaded_function.hpp>
+#include <boost/typeof/std/string.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <string>
+
+int add_i(int x, int y) { return x + y; }
+
+int main(void) {
+ std::string s = "abc";
+ std::string BOOST_LOCAL_FUNCTION(
+ (const bind& s) (const std::string& x) ) {
+ return s + x;
+ } BOOST_LOCAL_FUNCTION_NAME(add_s)
+
+ double d = 1.23;
+ double BOOST_LOCAL_FUNCTION( (const bind d) (double x)
+ (double y)(default 0) ) {
+ return d + x + y;
+ } BOOST_LOCAL_FUNCTION_NAME(add_d)
+
+ boost::overloaded_function<
+ std::string (const std::string&)
+ , double (double)
+ , double (double, double)
+ , int (int, int)
+ > add(add_s, add_d, add_d, add_i);
+
+ BOOST_TEST(add("xyz") == "abcxyz");
+ BOOST_TEST((4.44 - add(3.21)) <= 0.001); // Equal within precision.
+ BOOST_TEST((44.44 - add(3.21, 40.0)) <= 0.001); // Equal within precision.
+ BOOST_TEST(add(1, 2) == 3);
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/test/overload_seq_nova.cpp b/libs/local_function/test/overload_seq_nova.cpp
new file mode 100644
index 000000000..e72b63bde
--- /dev/null
+++ b/libs/local_function/test/overload_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "overload_seq.cpp"
+
diff --git a/libs/local_function/test/return_assign.cpp b/libs/local_function/test/return_assign.cpp
new file mode 100644
index 000000000..6637ffa92
--- /dev/null
+++ b/libs/local_function/test/return_assign.cpp
@@ -0,0 +1,49 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <iostream>
+
+//[return_assign
+void call1(boost::function<int (int) > f) { BOOST_TEST(f(1) == 5); }
+void call0(boost::function<int (void)> f) { BOOST_TEST(f() == 5); }
+
+boost::function<int (int, int)> linear(const int& slope) {
+ int BOOST_LOCAL_FUNCTION(const bind& slope,
+ int x, default 1, int y, default 2) {
+ return x + slope * y;
+ } BOOST_LOCAL_FUNCTION_NAME(lin)
+
+ boost::function<int (int, int)> f = lin; // Assign to local variable.
+ BOOST_TEST(f(1, 2) == 5);
+
+ call1(lin); // Pass to other functions.
+ call0(lin);
+
+ return lin; // Return.
+}
+
+void call(void) {
+ boost::function<int (int, int)> f = linear(2);
+ BOOST_TEST(f(1, 2) == 5);
+}
+//]
+
+int main(void) {
+ call();
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/return_assign_seq.cpp b/libs/local_function/test/return_assign_seq.cpp
new file mode 100644
index 000000000..95c6bf15e
--- /dev/null
+++ b/libs/local_function/test/return_assign_seq.cpp
@@ -0,0 +1,40 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <iostream>
+
+void call1(boost::function<int (int) > f) { BOOST_TEST(f(1) == 5); }
+void call0(boost::function<int (void)> f) { BOOST_TEST(f() == 5); }
+
+boost::function<int (int, int)> linear(const int& slope) {
+ int BOOST_LOCAL_FUNCTION( (const bind& slope)
+ (int x)(default 1) (int y)(default 2) ) {
+ return x + slope * y;
+ } BOOST_LOCAL_FUNCTION_NAME(lin)
+
+ boost::function<int (int, int)> f = lin;
+ BOOST_TEST(f(1, 2) == 5);
+
+ call1(lin);
+ call0(lin);
+
+ return lin;
+}
+
+void call(void) {
+ boost::function<int (int, int)> f = linear(2);
+ BOOST_TEST(f(1, 2) == 5);
+}
+
+int main(void) {
+ call();
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/test/return_assign_seq_nova.cpp b/libs/local_function/test/return_assign_seq_nova.cpp
new file mode 100644
index 000000000..12de8da2d
--- /dev/null
+++ b/libs/local_function/test/return_assign_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "return_assign_seq.cpp"
+
diff --git a/libs/local_function/test/return_derivative.cpp b/libs/local_function/test/return_derivative.cpp
new file mode 100644
index 000000000..746199132
--- /dev/null
+++ b/libs/local_function/test/return_derivative.cpp
@@ -0,0 +1,41 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function, 1)
+
+boost::function<int (int)> derivative(boost::function<int (int)>& f, int dx) {
+ int BOOST_LOCAL_FUNCTION(bind& f, const bind dx, int x) {
+ return (f(x + dx) - f(x)) / dx;
+ } BOOST_LOCAL_FUNCTION_NAME(deriv)
+
+ return deriv;
+}
+
+int main(void) {
+ int BOOST_LOCAL_FUNCTION(int x) {
+ return x + 4;
+ } BOOST_LOCAL_FUNCTION_NAME(add2)
+
+ boost::function<int (int)> a2 = add2; // Reference valid where closure used.
+ boost::function<int (int)> d2 = derivative(a2, 2);
+ BOOST_TEST(d2(6) == 1);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/return_derivative_seq.cpp b/libs/local_function/test/return_derivative_seq.cpp
new file mode 100644
index 000000000..72c207425
--- /dev/null
+++ b/libs/local_function/test/return_derivative_seq.cpp
@@ -0,0 +1,34 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::function, 1)
+
+boost::function<int (int)> derivative(boost::function<int (int)>& f, int dx) {
+ int BOOST_LOCAL_FUNCTION( (bind& f) (const bind dx) (int x) ) {
+ return (f(x + dx) - f(x)) / dx;
+ } BOOST_LOCAL_FUNCTION_NAME(deriv)
+
+ return deriv;
+}
+
+int main(void) {
+ int BOOST_LOCAL_FUNCTION( (int x) ) {
+ return x + 4;
+ } BOOST_LOCAL_FUNCTION_NAME(add2)
+
+ boost::function<int (int)> a2 = add2;
+ boost::function<int (int)> d2 = derivative(a2, 2);
+ BOOST_TEST(d2(6) == 1);
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/test/return_derivative_seq_nova.cpp b/libs/local_function/test/return_derivative_seq_nova.cpp
new file mode 100644
index 000000000..49bccdda3
--- /dev/null
+++ b/libs/local_function/test/return_derivative_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "return_derivative_seq.cpp"
+
diff --git a/libs/local_function/test/return_inc.cpp b/libs/local_function/test/return_inc.cpp
new file mode 100644
index 000000000..7d3e4248c
--- /dev/null
+++ b/libs/local_function/test/return_inc.cpp
@@ -0,0 +1,38 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::function<int (void)> inc(int& value) {
+ int BOOST_LOCAL_FUNCTION(bind& value) {
+ return ++value;
+ } BOOST_LOCAL_FUNCTION_NAME(i)
+ return i;
+}
+
+int main(void) {
+ int value1 = 0; // Reference valid in scope where closure is used.
+ boost::function<int (void)> inc1 = inc(value1);
+ int value2 = 0;
+ boost::function<int (void)> inc2 = inc(value2);
+
+ BOOST_TEST(inc1() == 1);
+ BOOST_TEST(inc1() == 2);
+ BOOST_TEST(inc2() == 1);
+ BOOST_TEST(inc1() == 3);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/return_inc_seq.cpp b/libs/local_function/test/return_inc_seq.cpp
new file mode 100644
index 000000000..6116ea990
--- /dev/null
+++ b/libs/local_function/test/return_inc_seq.cpp
@@ -0,0 +1,31 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+boost::function<int (void)> inc(int& value) {
+ int BOOST_LOCAL_FUNCTION( (bind& value) ) {
+ return ++value;
+ } BOOST_LOCAL_FUNCTION_NAME(i)
+ return i;
+}
+
+int main(void) {
+ int value1 = 0;
+ boost::function<int (void)> inc1 = inc(value1);
+ int value2 = 0;
+ boost::function<int (void)> inc2 = inc(value2);
+
+ BOOST_TEST(inc1() == 1);
+ BOOST_TEST(inc1() == 2);
+ BOOST_TEST(inc2() == 1);
+ BOOST_TEST(inc1() == 3);
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/test/return_inc_seq_nova.cpp b/libs/local_function/test/return_inc_seq_nova.cpp
new file mode 100644
index 000000000..c55ade6df
--- /dev/null
+++ b/libs/local_function/test/return_inc_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "return_inc_seq.cpp"
+
diff --git a/libs/local_function/test/return_setget.cpp b/libs/local_function/test/return_setget.cpp
new file mode 100644
index 000000000..1eb904c54
--- /dev/null
+++ b/libs/local_function/test/return_setget.cpp
@@ -0,0 +1,47 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/function.hpp>
+#include <boost/typeof/std/string.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <string>
+
+boost::function<void (const std::string&)> set;
+boost::function<const std::string& (void)> get;
+
+void action(void) {
+ // State `message` hidden behind access functions from here.
+ BOOST_TEST(get() == "abc");
+ set("xyz");
+ BOOST_TEST(get() == "xyz");
+}
+
+int main(void) {
+ std::string message = "abc"; // Reference valid where closure used.
+
+ void BOOST_LOCAL_FUNCTION(bind& message, const std::string& text) {
+ message = text;
+ } BOOST_LOCAL_FUNCTION_NAME(s)
+ set = s;
+
+ const std::string& BOOST_LOCAL_FUNCTION(const bind& message) {
+ return message;
+ } BOOST_LOCAL_FUNCTION_NAME(g)
+ get = g;
+
+ action();
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/return_setget_seq.cpp b/libs/local_function/test/return_setget_seq.cpp
new file mode 100644
index 000000000..33b1c35dd
--- /dev/null
+++ b/libs/local_function/test/return_setget_seq.cpp
@@ -0,0 +1,39 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/function.hpp>
+#include <boost/typeof/std/string.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <string>
+
+boost::function<void (const std::string&)> set;
+boost::function<const std::string& (void)> get;
+
+void action(void) {
+ BOOST_TEST(get() == "abc");
+ set("xyz");
+ BOOST_TEST(get() == "xyz");
+}
+
+int main(void) {
+ std::string message = "abc";
+
+ void BOOST_LOCAL_FUNCTION( (bind& message) (const std::string& text) ) {
+ message = text;
+ } BOOST_LOCAL_FUNCTION_NAME(s)
+ set = s;
+
+ const std::string& BOOST_LOCAL_FUNCTION( (const bind& message) ) {
+ return message;
+ } BOOST_LOCAL_FUNCTION_NAME(g)
+ get = g;
+
+ action();
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/test/return_setget_seq_nova.cpp b/libs/local_function/test/return_setget_seq_nova.cpp
new file mode 100644
index 000000000..87e2bde4c
--- /dev/null
+++ b/libs/local_function/test/return_setget_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "return_setget_seq.cpp"
+
diff --git a/libs/local_function/test/return_this.cpp b/libs/local_function/test/return_this.cpp
new file mode 100644
index 000000000..ea3debc86
--- /dev/null
+++ b/libs/local_function/test/return_this.cpp
@@ -0,0 +1,50 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+
+struct number;
+BOOST_TYPEOF_REGISTER_TYPE(number) // Register before `bind this_` below.
+
+struct number {
+ number(int value) : value_(value) {}
+
+ boost::function<int (void)> inc(void) {
+ int BOOST_LOCAL_FUNCTION(bind this_) {
+ return ++this_->value_;
+ } BOOST_LOCAL_FUNCTION_NAME(i)
+ return i;
+ }
+
+private:
+ int value_;
+};
+
+int main(void) {
+ number n1 = 0; // Object valid in scope where closure is used.
+ boost::function<int (void)> inc1 = n1.inc();
+ number n2 = 0;
+ boost::function<int (void)> inc2 = n2.inc();
+
+ BOOST_TEST(inc1() == 1);
+ BOOST_TEST(inc1() == 2);
+ BOOST_TEST(inc2() == 1);
+ BOOST_TEST(inc1() == 3);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/return_this_seq.cpp b/libs/local_function/test/return_this_seq.cpp
new file mode 100644
index 000000000..551d3e1b1
--- /dev/null
+++ b/libs/local_function/test/return_this_seq.cpp
@@ -0,0 +1,43 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/function.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/detail/lightweight_test.hpp>
+
+struct number;
+BOOST_TYPEOF_REGISTER_TYPE(number) // Register before `bind this_` below.
+
+struct number {
+ number(int value) : value_(value) {}
+
+ boost::function<int (void)> inc(void) {
+ int BOOST_LOCAL_FUNCTION( (bind this_) ) {
+ return ++this_->value_;
+ } BOOST_LOCAL_FUNCTION_NAME(i)
+ return i;
+ }
+
+private:
+ int value_;
+};
+
+int main(void) {
+ number n1 = 0; // Object valid in scope where closure is used.
+ boost::function<int (void)> inc1 = n1.inc();
+ number n2 = 0;
+ boost::function<int (void)> inc2 = n2.inc();
+
+ BOOST_TEST(inc1() == 1);
+ BOOST_TEST(inc1() == 2);
+ BOOST_TEST(inc2() == 1);
+ BOOST_TEST(inc1() == 3);
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/test/return_this_seq_nova.cpp b/libs/local_function/test/return_this_seq_nova.cpp
new file mode 100644
index 000000000..1f0cfc258
--- /dev/null
+++ b/libs/local_function/test/return_this_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "return_this_seq.cpp"
+
diff --git a/libs/local_function/test/same_line.cpp b/libs/local_function/test/same_line.cpp
new file mode 100644
index 000000000..0809e024f
--- /dev/null
+++ b/libs/local_function/test/same_line.cpp
@@ -0,0 +1,57 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/preprocessor/cat.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <iostream>
+
+//[same_line
+#define LOCAL_INC_DEC(offset) \
+ int BOOST_LOCAL_FUNCTION_ID(BOOST_PP_CAT(inc, __LINE__), /* unique ID */ \
+ const bind offset, const int x) { \
+ return x + offset; \
+ } BOOST_LOCAL_FUNCTION_NAME(inc) \
+ \
+ int BOOST_LOCAL_FUNCTION_ID(BOOST_PP_CAT(dec, __LINE__), \
+ const bind offset, const int x) { \
+ return x - offset; \
+ } BOOST_LOCAL_FUNCTION_NAME(dec)
+
+#define LOCAL_INC_DEC_TPL(offset) \
+ T BOOST_LOCAL_FUNCTION_ID_TPL(BOOST_PP_CAT(inc, __LINE__), \
+ const bind offset, const T x) { \
+ return x + offset; \
+ } BOOST_LOCAL_FUNCTION_NAME_TPL(inc) \
+ \
+ T BOOST_LOCAL_FUNCTION_ID_TPL(BOOST_PP_CAT(dec, __LINE__), \
+ const bind offset, const T x) { \
+ return x - offset; \
+ } BOOST_LOCAL_FUNCTION_NAME_TPL(dec)
+
+template<typename T>
+void f(T& delta) {
+ LOCAL_INC_DEC_TPL(delta) // Multiple local functions on same line.
+ BOOST_TEST(dec(inc(123)) == 123);
+}
+
+int main(void) {
+ int delta = 10;
+ LOCAL_INC_DEC(delta) // Multiple local functions on same line.
+ BOOST_TEST(dec(inc(123)) == 123);
+ f(delta);
+ return boost::report_errors();
+}
+//]
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/same_line_seq.cpp b/libs/local_function/test/same_line_seq.cpp
new file mode 100644
index 000000000..2113f4752
--- /dev/null
+++ b/libs/local_function/test/same_line_seq.cpp
@@ -0,0 +1,48 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/preprocessor/cat.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <iostream>
+
+#define LOCAL_INC_DEC(offset) \
+ int BOOST_LOCAL_FUNCTION_ID(BOOST_PP_CAT(inc, __LINE__), /* unique ID */ \
+ (const bind offset) (const int x) ) { \
+ return x + offset; \
+ } BOOST_LOCAL_FUNCTION_NAME(inc) \
+ \
+ int BOOST_LOCAL_FUNCTION_ID(BOOST_PP_CAT(dec, __LINE__), \
+ (const bind offset) (const int x) ) { \
+ return x - offset; \
+ } BOOST_LOCAL_FUNCTION_NAME(dec)
+
+#define LOCAL_INC_DEC_TPL(offset) \
+ T BOOST_LOCAL_FUNCTION_ID_TPL(BOOST_PP_CAT(inc, __LINE__), \
+ (const bind offset) (const T x) ) { \
+ return x + offset; \
+ } BOOST_LOCAL_FUNCTION_NAME_TPL(inc) \
+ \
+ T BOOST_LOCAL_FUNCTION_ID_TPL(BOOST_PP_CAT(dec, __LINE__), \
+ (const bind offset) (const T x) ) { \
+ return x - offset; \
+ } BOOST_LOCAL_FUNCTION_NAME_TPL(dec)
+
+template<typename T>
+void f(T& delta) {
+ LOCAL_INC_DEC_TPL(delta) // Multiple local functions on same line.
+ BOOST_TEST(dec(inc(123)) == 123);
+}
+
+int main(void) {
+ int delta = 10;
+ LOCAL_INC_DEC(delta) // Declare local functions on same line using `_ID`.
+ BOOST_TEST(dec(inc(123)) == 123);
+ f(delta);
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/test/same_line_seq_nova.cpp b/libs/local_function/test/same_line_seq_nova.cpp
new file mode 100644
index 000000000..fb5cc174f
--- /dev/null
+++ b/libs/local_function/test/same_line_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "same_line_seq.cpp"
+
diff --git a/libs/local_function/test/ten_void.cpp b/libs/local_function/test/ten_void.cpp
new file mode 100644
index 000000000..99bf1bfdb
--- /dev/null
+++ b/libs/local_function/test/ten_void.cpp
@@ -0,0 +1,21 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+int main(void) {
+ //[ten_void
+ int BOOST_LOCAL_FUNCTION(void) { // No parameter.
+ return 10;
+ } BOOST_LOCAL_FUNCTION_NAME(ten)
+
+ BOOST_TEST(ten() == 10);
+ //]
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/test/ten_void_nova.cpp b/libs/local_function/test/ten_void_nova.cpp
new file mode 100644
index 000000000..64b01c56d
--- /dev/null
+++ b/libs/local_function/test/ten_void_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "ten_void.cpp"
+
diff --git a/libs/local_function/test/transform.cpp b/libs/local_function/test/transform.cpp
new file mode 100644
index 000000000..0cdbe76bc
--- /dev/null
+++ b/libs/local_function/test/transform.cpp
@@ -0,0 +1,47 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+#include <vector>
+
+int main(void) {
+ //[transform
+ int offset = 5;
+ std::vector<int> v;
+ std::vector<int> w;
+
+ for(int i = 1; i <= 2; ++i) v.push_back(i * 10);
+ BOOST_TEST(v[0] == 10); BOOST_TEST(v[1] == 20);
+ w.resize(v.size());
+
+ int BOOST_LOCAL_FUNCTION(const bind& offset, int i) {
+ return ++i + offset;
+ } BOOST_LOCAL_FUNCTION_NAME(inc)
+
+ std::transform(v.begin(), v.end(), w.begin(), inc);
+ BOOST_TEST(w[0] == 16); BOOST_TEST(w[1] == 26);
+
+ int BOOST_LOCAL_FUNCTION(bind& inc, int i, int j) {
+ return inc(i + j); // Call the other bound local function.
+ } BOOST_LOCAL_FUNCTION_NAME(inc_sum)
+
+ offset = 0;
+ std::transform(v.begin(), v.end(), w.begin(), v.begin(), inc_sum);
+ BOOST_TEST(v[0] == 27); BOOST_TEST(v[1] == 47);
+ //]
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/transform_seq.cpp b/libs/local_function/test/transform_seq.cpp
new file mode 100644
index 000000000..b29514c45
--- /dev/null
+++ b/libs/local_function/test/transform_seq.cpp
@@ -0,0 +1,39 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/local_function.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+#include <vector>
+
+int main(void) {
+ int offset = 5;
+ std::vector<int> v;
+ std::vector<int> w;
+
+ for(int i = 1; i <= 2; ++i) v.push_back(i * 10);
+ BOOST_TEST(v[0] == 10); BOOST_TEST(v[1] == 20);
+ w.resize(v.size());
+
+ int BOOST_LOCAL_FUNCTION( (const bind& offset) (int i) ) {
+ return ++i + offset;
+ } BOOST_LOCAL_FUNCTION_NAME(inc)
+
+ std::transform(v.begin(), v.end(), w.begin(), inc);
+ BOOST_TEST(w[0] == 16); BOOST_TEST(w[1] == 26);
+
+ int BOOST_LOCAL_FUNCTION( (bind& inc) (int i) (int j) ) {
+ return inc(i + j);
+ } BOOST_LOCAL_FUNCTION_NAME(inc_sum)
+
+ offset = 0;
+ std::transform(v.begin(), v.end(), w.begin(), v.begin(), inc_sum);
+ BOOST_TEST(v[0] == 27); BOOST_TEST(v[1] == 47);
+
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/test/transform_seq_nova.cpp b/libs/local_function/test/transform_seq_nova.cpp
new file mode 100644
index 000000000..9f06e4fb1
--- /dev/null
+++ b/libs/local_function/test/transform_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "transform_seq.cpp"
+
diff --git a/libs/local_function/test/typeof.cpp b/libs/local_function/test/typeof.cpp
new file mode 100644
index 000000000..aa347354a
--- /dev/null
+++ b/libs/local_function/test/typeof.cpp
@@ -0,0 +1,41 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include "addable.hpp"
+#include <boost/local_function.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/concept_check.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+
+int main(void) {
+ //[typeof
+ int sum = 0, factor = 10;
+
+ void BOOST_LOCAL_FUNCTION(const bind factor, bind& sum, int num) {
+ // Type-of for concept checking.
+ BOOST_CONCEPT_ASSERT((Addable<boost::remove_reference<
+ BOOST_LOCAL_FUNCTION_TYPEOF(sum)>::type>));
+ // Type-of for declarations.
+ boost::remove_reference<BOOST_LOCAL_FUNCTION_TYPEOF(
+ factor)>::type mult = factor * num;
+ sum += mult;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ add(6);
+ //]
+ BOOST_TEST(sum == 60);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/typeof_seq.cpp b/libs/local_function/test/typeof_seq.cpp
new file mode 100644
index 000000000..01dd4633e
--- /dev/null
+++ b/libs/local_function/test/typeof_seq.cpp
@@ -0,0 +1,30 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "addable.hpp"
+#include <boost/local_function.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/concept_check.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+
+int main(void) {
+ int sum = 0, factor = 10;
+
+ void BOOST_LOCAL_FUNCTION( (const bind factor) (bind& sum) (int num) ) {
+ BOOST_CONCEPT_ASSERT((Addable<boost::remove_reference<
+ BOOST_LOCAL_FUNCTION_TYPEOF(sum)>::type>));
+ boost::remove_reference<BOOST_LOCAL_FUNCTION_TYPEOF(
+ factor)>::type mult = factor * num;
+ sum += mult;
+ } BOOST_LOCAL_FUNCTION_NAME(add)
+
+ add(6);
+ BOOST_TEST(sum == 60);
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/test/typeof_seq_nova.cpp b/libs/local_function/test/typeof_seq_nova.cpp
new file mode 100644
index 000000000..bf8b982be
--- /dev/null
+++ b/libs/local_function/test/typeof_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "typeof_seq.cpp"
+
diff --git a/libs/local_function/test/typeof_template.cpp b/libs/local_function/test/typeof_template.cpp
new file mode 100644
index 000000000..f74e49fcd
--- /dev/null
+++ b/libs/local_function/test/typeof_template.cpp
@@ -0,0 +1,43 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include <boost/config.hpp>
+#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
+# error "variadic macros required"
+#else
+
+#include "addable.hpp"
+#include <boost/local_function.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/concept_check.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+
+//[typeof_template
+template<typename T>
+T calculate(const T& factor) {
+ T sum = 0;
+
+ void BOOST_LOCAL_FUNCTION_TPL(const bind factor, bind& sum, T num) {
+ // Local function `TYPEOF` does not need `typename`.
+ BOOST_CONCEPT_ASSERT((Addable<typename boost::remove_reference<
+ BOOST_LOCAL_FUNCTION_TYPEOF(sum)>::type>));
+ sum += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME_TPL(add)
+
+ add(6);
+ return sum;
+}
+//]
+
+int main(void) {
+ BOOST_TEST(calculate(10) == 60);
+ return boost::report_errors();
+}
+
+#endif // VARIADIC_MACROS
+
diff --git a/libs/local_function/test/typeof_template_seq.cpp b/libs/local_function/test/typeof_template_seq.cpp
new file mode 100644
index 000000000..60028e958
--- /dev/null
+++ b/libs/local_function/test/typeof_template_seq.cpp
@@ -0,0 +1,33 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "addable.hpp"
+#include <boost/local_function.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/concept_check.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <algorithm>
+
+template<typename T>
+T calculate(const T& factor) {
+ T sum = 0;
+
+ void BOOST_LOCAL_FUNCTION_TPL( (const bind factor) (bind& sum) (T num) ) {
+ BOOST_CONCEPT_ASSERT((Addable<typename boost::remove_reference<
+ BOOST_LOCAL_FUNCTION_TYPEOF(sum)>::type>));
+ sum += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME_TPL(add)
+
+ add(6);
+ return sum;
+}
+
+int main(void) {
+ BOOST_TEST(calculate(10) == 60);
+ return boost::report_errors();
+}
+
diff --git a/libs/local_function/test/typeof_template_seq_nova.cpp b/libs/local_function/test/typeof_template_seq_nova.cpp
new file mode 100644
index 000000000..48df4d431
--- /dev/null
+++ b/libs/local_function/test/typeof_template_seq_nova.cpp
@@ -0,0 +1,10 @@
+
+// Copyright (C) 2009-2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/local_function
+
+#include "nova.hpp"
+#include "typeof_template_seq.cpp"
+