|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r77943 - in trunk: boost boost/local_function libs/local_function/doc libs/local_function/doc/html libs/local_function/doc/html/boost_localfunction libs/local_function/example libs/local_function/test libs/scope_exit/doc libs/scope_exit/doc/html libs/scope_exit/doc/html/scope_exit
From: lorcaminiti_at_[hidden]
Date: 2012-04-12 20:26:17
Author: lcaminiti
Date: 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
New Revision: 77943
URL: http://svn.boost.org/trac/boost/changeset/77943
Log:
Updated docs.
Text files modified:
trunk/boost/local_function.hpp | 255 ++++++++++++++------
trunk/boost/local_function/config.hpp | 36 ++
trunk/libs/local_function/doc/acknowledgements.qbk | 8
trunk/libs/local_function/doc/advanced_topics.qbk | 150 ++++++------
trunk/libs/local_function/doc/alternatives.qbk | 82 +++---
trunk/libs/local_function/doc/examples.qbk | 75 +++--
trunk/libs/local_function/doc/getting_started.qbk | 17
trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION.html | 16
trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html | 2
trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html | 2
trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html | 18 +
trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_ID.html | 27 +-
trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_NAME.html | 35 +-
trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_NAME_TPL.html | 19 +
trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TPL.html | 14
trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TYPEOF.html | 6
trunk/libs/local_function/doc/html/boost_localfunction/Acknowledgments.html | 15
trunk/libs/local_function/doc/html/boost_localfunction/Advanced_Topics.html | 473 ++++++++++++++++++++++-----------------
trunk/libs/local_function/doc/html/boost_localfunction/Alternatives.html | 252 +++++++++++++-------
trunk/libs/local_function/doc/html/boost_localfunction/Examples.html | 249 +++++++++++++++-----
trunk/libs/local_function/doc/html/boost_localfunction/Getting_Started.html | 36 +-
trunk/libs/local_function/doc/html/boost_localfunction/Implementation.html | 48 ++-
trunk/libs/local_function/doc/html/boost_localfunction/No_Variadic_Macros.html | 16
trunk/libs/local_function/doc/html/boost_localfunction/Release_Notes.html | 15 +
trunk/libs/local_function/doc/html/boost_localfunction/Tutorial.html | 136 +++++------
trunk/libs/local_function/doc/html/index.html | 25 +-
trunk/libs/local_function/doc/html/reference.html | 9
trunk/libs/local_function/doc/implementation.qbk | 14
trunk/libs/local_function/doc/introduction.qbk | 8
trunk/libs/local_function/doc/local_function.qbk | 9
trunk/libs/local_function/doc/no_variadic_macros.qbk | 6
trunk/libs/local_function/doc/release_notes.qbk | 5
trunk/libs/local_function/doc/tutorial.qbk | 47 +--
trunk/libs/local_function/example/Jamfile.v2 | 1
trunk/libs/local_function/example/add_global_functor.cpp | 1
trunk/libs/local_function/example/add_local_functor.cpp | 1
trunk/libs/local_function/example/const_block.hpp | 10
trunk/libs/local_function/example/expensive_copy_cxx11_lambda.cpp | 1
trunk/libs/local_function/example/gcc_lambda.hpp | 4
trunk/libs/local_function/example/impl_tparam_tricks.cpp | 13
trunk/libs/local_function/example/noncopyable_cxx11_lambda_error.cpp | 3
trunk/libs/local_function/example/noncopyable_local_function.cpp | 2
trunk/libs/local_function/example/scope_exit.hpp | 4
trunk/libs/local_function/test/add.cpp | 2
trunk/libs/local_function/test/add_inline.cpp | 2
trunk/libs/local_function/test/add_typed.cpp | 4
trunk/libs/local_function/test/add_typed_seq.cpp | 4
trunk/libs/local_function/test/goto.cpp | 4
trunk/libs/local_function/test/goto_error.cpp | 4
trunk/libs/local_function/test/goto_error_seq.cpp | 4
trunk/libs/local_function/test/goto_seq.cpp | 4
trunk/libs/local_function/test/operator_error.cpp | 4
trunk/libs/local_function/test/overload.cpp | 5
trunk/libs/local_function/test/same_line.cpp | 33 ++
trunk/libs/local_function/test/same_line_seq.cpp | 28 ++
trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT.html | 2
trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_ALL.html | 2
trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_ALL_ID.html | 2
trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_CONFIG_USE_LAMBDAS.html | 2
trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_END.html | 2
trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_END_ID.html | 2
trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_ID.html | 2
trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_TPL.html | 2
trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_TPL_ID.html | 2
trunk/libs/scope_exit/doc/html/index.html | 2
trunk/libs/scope_exit/doc/html/scope_exit/Getting_Started.html | 9
trunk/libs/scope_exit/doc/scope_exit.qbk | 4
67 files changed, 1403 insertions(+), 893 deletions(-)
Modified: trunk/boost/local_function.hpp
==============================================================================
--- trunk/boost/local_function.hpp (original)
+++ trunk/boost/local_function.hpp 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -21,28 +21,25 @@
// PUBLIC //
#ifdef BOOST_NO_VARIADIC_MACROS
-# define BOOST_LOCAL_FUNCTION_ID(id, within_template, declarations) \
- BOOST_LOCAL_FUNCTION_AUX_DECL(id, within_template, \
+# define BOOST_LOCAL_FUNCTION(declarations) \
+ BOOST_LOCAL_FUNCTION_AUX_DECL(id, 0 /* not within template */, \
BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS( \
BOOST_LOCAL_FUNCTION_DETAIL_PP_VOID_LIST( \
declarations)))
-# define BOOST_LOCAL_FUNCTION(declarations) \
- BOOST_LOCAL_FUNCTION_ID(BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER, \
- 0, declarations)
# define BOOST_LOCAL_FUNCTION_TPL(declarations) \
- BOOST_LOCAL_FUNCTION_ID(BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER, \
- 1, declarations)
+ BOOST_LOCAL_FUNCTION_AUX_DECL(id, 1 /* within template */, \
+ BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS( \
+ BOOST_LOCAL_FUNCTION_DETAIL_PP_VOID_LIST( \
+ declarations)))
#else // VARIADIC
-# define BOOST_LOCAL_FUNCTION_ID(id, within_template, ...) \
- BOOST_LOCAL_FUNCTION_AUX_DECL(id, within_template, \
+# define BOOST_LOCAL_FUNCTION(...) \
+ BOOST_LOCAL_FUNCTION_AUX_DECL(id, 0 /* not within template */, \
BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS( \
BOOST_LOCAL_FUNCTION_DETAIL_PP_VOID_LIST(__VA_ARGS__)))
-# define BOOST_LOCAL_FUNCTION(...) \
- BOOST_LOCAL_FUNCTION_ID( \
- BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER, 0, __VA_ARGS__)
# define BOOST_LOCAL_FUNCTION_TPL(...) \
- BOOST_LOCAL_FUNCTION_ID( \
- BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER, 1, __VA_ARGS__)
+ BOOST_LOCAL_FUNCTION_AUX_DECL(id, 1 /* within template */, \
+ BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS( \
+ BOOST_LOCAL_FUNCTION_DETAIL_PP_VOID_LIST(__VA_ARGS__)))
#endif // VARIADIC
#define BOOST_LOCAL_FUNCTION_NAME(qualified_function_name) \
@@ -60,8 +57,8 @@
#else // DOXYGEN
/** @file
-_at_brief Local functions allow to program functions locally, directly within the
-scope where they are needed.
+@brief Local functions allow to program functions locally, within other
+functions, and directly within the scope where they are needed.
*/
/**
@@ -76,7 +73,7 @@
...
result_type BOOST_LOCAL_FUNCTION(declarations) {
... // Body code.
- } BOOST_LOCAL_FUNCTION_NAME(qualified_function_name)
+ } BOOST_LOCAL_FUNCTION_NAME(qualified_name)
...
}
@endcode
@@ -87,8 +84,8 @@
automatically generated by the macro expansion, see the
@RefSectId{Advanced_Topics, Advanced Topics} section).
-Within templates, the special macro @RefMacro{BOOST_LOCAL_FUNCTION_TPL} must be
-used instead of_at_RefMacro{BOOST_LOCAL_FUNCTION}.
+Within templates, the special macros @RefMacro{BOOST_LOCAL_FUNCTION_TPL}
+and @RefMacro{BOOST_LOCAL_FUNCTION_NAME_TPL} must be used.
@Params
@Param{declarations,
@@ -119,16 +116,15 @@
void | declaration_sequence
@endcode
-Lexical conventions: <c>token1 | token2</c> means either <c>token1</c> or
+(Lexical conventions: <c>token1 | token2</c> means either <c>token1</c> or
<c>token2</c>; <c>[token]</c> means either <c>token</c> or nothing;
-<c>{expression}</c> means the token resulting from the expression.
+<c>{expression}</c> means the token resulting from the expression.)
}
@EndParams
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.
+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 <c>()</c>.
@@ -144,96 +140,151 @@
Within the local function body it possible to access the result type using <c>result_type</c>, the type of the first parameter using <c>arg1_type</c>, the type of the second parameter using <c>arg2_type</c>, etc.
The bound variable types can be accessed using @RefMacro{BOOST_LOCAL_FUNCTION_TYPEOF}.
+This macro cannot be portably expanded multiple times on the same line.
+In these cases, use the @RefMacro{BOOST_LOCAL_FUNCTION_ID} macro instead.
+
The maximum number of local function parameters (excluding bound variables) is
specified by the configuration macro
@RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX}.
The maximum number of bound variables is specified by the configuration macro
@RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX}.
+The configuration macro
+@RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS} can be used to force
+optimizations that reduce the local function call run-time overhead.
@Note Local functions are functors so they can be assigned to other functors
like <c>boost::function</c> (see Boost.Function).
-_at_Note This macro cannot be portably used multiple times on the same line
-(because on GCC and other compilers, it internally uses the line number
-<c>__LINE__</c> to generate unique identifiers).
-
-_at_See @RefSect{Tutorial} section,
-_at_RefSectId{Advanced_Topics, Advanced Topics} section,
-_at_RefMacro{BOOST_LOCAL_FUNCTION_TPL},
-_at_RefMacro{BOOST_LOCAL_FUNCTION_NAME},
-_at_RefMacro{BOOST_LOCAL_FUNCTION_TYPEOF},
+@See @RefSect{Tutorial} section, @RefSectId{Advanced_Topics, Advanced Topics}
+section, @RefMacro{BOOST_LOCAL_FUNCTION_NAME},
+@RefMacro{BOOST_LOCAL_FUNCTION_TPL}, @RefMacro{BOOST_LOCAL_FUNCTION_NAME_TPL},
+@RefMacro{BOOST_LOCAL_FUNCTION_TYPEOF}, @RefMacro{BOOST_LOCAL_FUNCTION_ID},
@RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX},
-_at_RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX}.
+@RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX},
+@RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS}.
*/
#define BOOST_LOCAL_FUNCTION(declarations)
/**
-_at_brief This macro is used to start a local function declaration within templates.
+@brief This macro is used to start a local function declaration within
+templates.
-This macro must be used instead of @RefMacro{BOOST_LOCAL_FUNCTION} when declaring a local function within a template.
-A part from that, this macro has the exact same syntax as @RefMacro{BOOST_LOCAL_FUNCTION} (see @RefMacro{BOOST_LOCAL_FUNCTION} for more information):
+This macro must be used instead of @RefMacro{BOOST_LOCAL_FUNCTION} when
+declaring a local function within a template.
+A part from that, this macro has the exact same syntax a
+@RefMacro{BOOST_LOCAL_FUNCTION} (see @RefMacro{BOOST_LOCAL_FUNCTION} for more
+information):
@code
-{ // Some declarative context with a template.
+{ // Some declarative context within a template.
...
result_type BOOST_LOCAL_FUNCTION_TPL(declarations) {
... // Body code.
- } BOOST_LOCAL_FUNCTION_NAME(qualified_function_name)
+ } BOOST_LOCAL_FUNCTION_NAME_TPL(qualified_name)
...
}
@endcode
+Note that @RefMacro{BOOST_LOCAL_FUNCTION_NAME_TPL} must be used with this
+macro instead of @RefMacro{BOOST_LOCAL_FUNCTION_NAME}.
+
+This macro cannot be portably expanded multiple times on the same line.
+In these cases, use the @RefMacro{BOOST_LOCAL_FUNCTION_TPL_ID} macro instead.
+
@Note C++03 does not allow to use <c>typename</c> outside templates.
This library internally manipulates types, these operations require
-<c>typename</c> but only within templates so this macro is used to indicate to
-the library when the enclosing scope is a template.
+<c>typename</c> 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 <c>typename</c>.
@See @RefSect{Tutorial} section, @RefMacro{BOOST_LOCAL_FUNCTION},
-_at_RefMacro{BOOST_LOCAL_FUNCTION_NAME}.
+@RefMacro{BOOST_LOCAL_FUNCTION_TPL_ID},
+@RefMacro{BOOST_LOCAL_FUNCTION_NAME_TPL}.
*/
#define BOOST_LOCAL_FUNCTION_TPL(declarations)
/**
-_at_brief This macro allows to expand multiple local function macros on the same
-line.
+@brief This macro allows to declare multiple local functions on the same line.
This macro is equivalent to @RefMacro{BOOST_LOCAL_FUNCTION} but it can be
expanded multiple times on the same line if different identifiers <c>id</c> are
-provided for each expansion (see @RefMacro{BOOST_LOCAL_FUNCTION} for more
-detail).
+provided for each expansion (see the
+@RefSectId{Advanced_Topics, Advanced Topics} section).
@Params
@Param{id,
- A unique identifier token which can be catted by the preprocessor (for
- example <c>__LINE__</c> or <c>local_function_number_1_on_line_123</c>).
-}
-_at_Param{within_template,
- Specify <c>1</c> when this macro is used in a type-dependant context\,
- <c>0</c> otherwise (this is equivalent to using
- @RefMacro{BOOST_LOCAL_FUNCTION_TPL} on separate lines).
+A unique identifier token which can be concatenated by the preprocessor
+(<c>__LINE__</c>\, <c>local_function_number_1_on_line_123</c>\, etc).
}
@Param{declarations,
- Same as the <c>declarations</c> parameter of the
- @RefMacro{BOOST_LOCAL_FUNCTION} macro.
+Same as the <c>declarations</c> parameter of the
+@RefMacro{BOOST_LOCAL_FUNCTION} macro.
}
@EndParams
+The @RefMacro{BOOST_LOCAL_FUNCTION_NAME} 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).
+
+Within templates, the special macros @RefMacro{BOOST_LOCAL_FUNCTION_TPL_ID}
+must be used.
+
@Note 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
+On some compilers (e.g., MSVC which supports the non-standard
<c>__COUNTER__</c> 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 <c>__LINE__</c> to internally generate unique
identifiers).
-_at_Note The @RefMacro{BOOST_LOCAL_FUNCTION_NAME} macro can always be expanded
-multiple times on the same line because a unique local function name must be
-provided for each different expansion (so the is no need for a
-<c>BOOST_LOCAL_FUNCTION_NAME_ID</c> macro).
+@See @RefSectId{Advanced_Topics, Advanced Topics} section,
+@RefMacro{BOOST_LOCAL_FUNCTION}, @RefMacro{BOOST_LOCAL_FUNCTION_NAME},
+@RefMacro{BOOST_LOCAL_FUNCTION_TPL_ID}.
+*/
+#define BOOST_LOCAL_FUNCTION_ID(id, declarations)
+
+/**
+@brief This macro allows to declare multiple local functions on the same line
+within templates.
+
+This macro must be used instead of @RefMacro{BOOST_LOCAL_FUNCTION_TPL} when
+declaring multiple local functions on the same line within a template.
+A part from that, this macro has the exact same syntax as
+@RefMacro{BOOST_LOCAL_FUNCTION_TPL} (see @RefMacro{BOOST_LOCAL_FUNCTION_TPL}
+for more information).
+
+@Params
+@Param{id,
+A unique identifier token which can be concatenated by the preprocessor
+(<c>__LINE__</c>\, <c>local_function_number_1_on_line_123</c>\, etc).
+}
+@Param{declarations,
+Same as the <c>declarations</c> parameter of the
+@RefMacro{BOOST_LOCAL_FUNCTION_TPL} macro.
+}
+@EndParams
+
+The @RefMacro{BOOST_LOCAL_FUNCTION_NAME} 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).
-_at_See @RefMacro{BOOST_LOCAL_FUNCTION}, @RefMacro{BOOST_LOCAL_FUNCTION_TPL}.
+Outside template, the macro @RefMacro{BOOST_LOCAL_FUNCTION_ID} should be used
+to declare multiple local functions on the same line.
+
+@Note 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
+<c>__COUNTER__</c> 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 <c>__LINE__</c> to internally generate unique
+identifiers).
+
+@See @RefSectId{Advanced_Topics, Advanced Topics} section,
+@RefMacro{BOOST_LOCAL_FUNCTION_TPL}, @RefMacro{BOOST_LOCAL_FUNCTION_NAME},
+@RefMacro{BOOST_LOCAL_FUNCTION_ID}.
*/
-#define BOOST_LOCAL_FUNCTION_ID(id, within_template, declarations)
+#define BOOST_LOCAL_FUNCTION_TPL_ID(id, declarations)
/**
@brief This macro is used to end a local function declaration specifying its
@@ -245,48 +296,61 @@
...
result_type BOOST_LOCAL_FUNCTION(declarations) {
... // Body code.
- } BOOST_LOCAL_FUNCTION_NAME(name)
+ } BOOST_LOCAL_FUNCTION_NAME(qualified_name)
...
}
@endcode
+Within templates, the special macros @RefMacro{BOOST_LOCAL_FUNCTION_TPL} and
+@RefMacro{BOOST_LOCAL_FUNCTION_NAME_TPL} must be used.
+
@Params
-_at_Param{name,
+@Param{qualified_name,
The name of the local function optionally qualified as follow:
@code
-name:
- [(function_type)[(defaults)]] [inline] [recursive] function_name
+ name:
+ [inline] [recursive] local_function_name
@endcode
-Lexical conventions: <c>token1 | token2</c> means either <c>token1</c> or
+(Lexical conventions: <c>token1 | token2</c> means either <c>token1</c> or
<c>token2</c>; <c>[token]</c> means either <c>token</c> or nothing;
-<c>{expression}</c> means the token resulting from the expression.
+<c>{expression}</c> means the token resulting from the expression.)
}
@EndParams
The local function name can be qualified by prefixing it with the keyword
<c>inline</c> (see the @RefSectId{Advanced_Topics, Advanced Topics} section):
-<c>BOOST_LOCAL_FUNCTION_NAME(inline name)</c>.
+@code
+ BOOST_LOCAL_FUNCTION_NAME(inline local_function_name)
+@endcode
This increases the chances that the compiler will be able to inline the local
function calls (thus reducing run-time).
-However, inlined local functions cannot be passed as template parameters (e.g., to <c>std::for_each</c>) or assigned to other functors (e.g., to
+However, inline local functions cannot be passed as template parameters (e.g., to <c>std::for_each</c>) or assigned to other functors (e.g., to
<c>boost::function</c>).
-That is true on C++03 compilers but inlined local functions can instead be
+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
+<c>BOOST_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS</c> is not defined but it also be
+forced using @RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS}.
The local function name can also be qualified by prefixing it with the
"keyword" <c>recursive</c> (see the
@RefSectId{Advanced_Topics, Advanced Topics} section):
-<c>BOOST_LOCAL_FUNCTION_NAME(recursive name)</c>.
+@code
+ BOOST_LOCAL_FUNCTION_NAME(recursive local_function_name)
+@endcode
This allows the local function to recursively call itself from its body (as
usual in C++).
-However, 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: <c>BOOST_LOCAL_FUNCTION(inline recursive name)</c>).
-Furthermore, recursive local functions should only be called within their
+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:
+@code
+ BOOST_LOCAL_FUNCTION(inline recursive local_function_name)
+@endcode
@Note The local function name cannot be the name of an operator
<c>operator...</c> and it cannot be the same name of another local function
@@ -297,12 +361,41 @@
@See @RefSect{Tutorial} section,
@RefSectId{Advanced_Topics, Advanced Topics} section,
-_at_RefMacro{BOOST_LOCAL_FUNCTION}.
+@RefMacro{BOOST_LOCAL_FUNCTION},
+@RefMacro{BOOST_LOCAL_FUNCTION_NAME_TPL}.
*/
-#define BOOST_LOCAL_FUNCTION_NAME(name)
+#define BOOST_LOCAL_FUNCTION_NAME(qualified_name)
/**
-In type-dependant context.
+@brief This macro is used to end a local function declaration specifying its
+name within templates.
+
+This macro must be used instead of @RefMacro{BOOST_LOCAL_FUNCTION_NAME} when
+declaring a local function within a template.
+A part from that, this macro has the exact same syntax a
+@RefMacro{BOOST_LOCAL_FUNCTION_NAME} (see @RefMacro{BOOST_LOCAL_FUNCTION_NAME}
+for more information):
+@code
+{ // Some declarative context within a template.
+ ...
+ result_type BOOST_LOCAL_FUNCTION_TPL(declarations) {
+ ... // Body code.
+ } BOOST_LOCAL_FUNCTION_NAME_TPL(qualified_name)
+ ...
+}
+@endcode
+
+Note that @RefMacro{BOOST_LOCAL_FUNCTION_TPL} must be used with this macro
+instead of @RefMacro{BOOST_LOCAL_FUNCTION}.
+
+@Note C++03 does not allow to use <c>typename</c> outside templates.
+This library internally manipulates types, these operations require
+<c>typename</c> 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 <c>typename</c>.
+
+@See @RefSect{Tutorial} section, @RefMacro{BOOST_LOCAL_FUNCTION_NAME},
+@RefMacro{BOOST_LOCAL_FUNCTION_TPL}.
*/
#define BOOST_LOCAL_FUNCTION_NAME_TPL(name)
@@ -337,9 +430,11 @@
@li Bound by constant reference using <c>const bind& t</c> then
<c>BOOST_LOCAL_FUNCTION_TYPEOF(t)</c> is <c>const T&</c>.
-This macro must be prefixed by <c>typename</c> when used in a type dependant context.
+This macro must be prefixed by <c>typename</c> when used within templates.
-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 @RefSectId{Advanced_Topics, Advanced Topics} section).
+@Note 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
+@RefSectId{Advanced_Topics, Advanced Topics} section).
@See @RefSectId{Advanced_Topics, Advanced Topics} section,
@RefMacro{BOOST_LOCAL_FUNCTION}.
Modified: trunk/boost/local_function/config.hpp
==============================================================================
--- trunk/boost/local_function/config.hpp (original)
+++ trunk/boost/local_function/config.hpp 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -71,10 +71,38 @@
#define BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX
/**
-Control performance optimizations.
-Automatically set using Boost.Config BOOST_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS
-if not defined by user.
-0 - no optimization, 1 - optimization.
+@brief Specify when local functions can be passed as template parameters
+without introducing any run-time overhead.
+
+If this macro is defined to <c>1</c>, this library will assume that the
+compiler allows to pass local classes as template parameters:
+@code
+ template<typename T> void f(void) {}
+
+ int main(void) {
+ struct local_class {};
+ f<local_class>();
+ return 0;
+ }
+@endcode
+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).
+
+If this macro is defined to <c>0</c> 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.
+
+It is recommended to leave this macro undefined.
+In this case, the library will automatically define this macro to <c>0</c> if
+the Boost.Config macro <c>BOOST_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS</c> is
+defined for the specific compiler, and to <c>1</c> otherwise.
+
+@See @RefSectId{Getting_Started, Getting Started} section,
+@RefSectId{Advanced_Topics, Advanced Topics} section,
+@RefMacro{BOOST_LOCAL_FUNCTION_NAME}.
*/
#define BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS
Modified: trunk/libs/local_function/doc/acknowledgements.qbk
==============================================================================
--- trunk/libs/local_function/doc/acknowledgements.qbk (original)
+++ trunk/libs/local_function/doc/acknowledgements.qbk 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -9,7 +9,7 @@
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://boost.2283326.n4.nabble.com/contract-diff-n1962-tt2671482.html#none emulate local functions].
+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].
@@ -25,9 +25,9 @@
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 the library's [@http://lists.boost.org/boost-announce/2011/12/0340.php Boost review] manager: Jeffrey Lee Hellrung.
-Thanks also to all the people that submitted a (positive and negative) 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 else that commented (positively and negatively) on the library during its Boost review.
+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.
Modified: trunk/libs/local_function/doc/advanced_topics.qbk
==============================================================================
--- trunk/libs/local_function/doc/advanced_topics.qbk (original)
+++ trunk/libs/local_function/doc/advanced_topics.qbk 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -7,17 +7,18 @@
[section:Advanced_Topics Advanced Topics]
-This section illustrates advanced usages of this library (at the bottom there is also a list of known limitations of the library).
+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 also allows to specify default values for the local function 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 then to count the number of default values to provide the correct set of call operators for the local functor.
+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:
@@ -28,10 +29,10 @@
[add_default]
-Programmers can define a `WITH_DEFAULT` macro similar to the following if they think it improves readability over the syntax above (see also [@../../test/add_with_default.cpp =add_with_default.cpp=]):
+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.
+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]
@@ -42,7 +43,7 @@
[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 the local function parameters and bindings will generate (cryptic) preprocessor errors unless they are wrapped with an extra set of round parenthesis `()` as explained here.
+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).
@@ -74,7 +75,7 @@
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(`[^['parenthesized-type]]`)` from the header =boost/utility/identity_type.hpp= can be used to wrap a type within extra parenthesis `()` so to overcome the problem:
+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>
@@ -85,7 +86,7 @@
...
} BOOST_LOCAL_FUNCTION_NAME(f)
-This macro expands to an expression that evaluates (at compile-time) exactly to the specified type.
+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.
@@ -102,7 +103,7 @@
) 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 macros `BOOST_IDENTITY_TYPE` can also be used to overcome this issue:
+The `BOOST_IDENTITY_TYPE` macro can also be used to overcome this issue:
void BOOST_LOCAL_FUNCTION(
...
@@ -128,7 +129,7 @@
[*(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 be simply wrapped within an extra set of round parenthesis `()`:
+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(
...
@@ -149,21 +150,19 @@
[section Assignments and Returns]
-Local functions are function objects so it is possible to assign them to other functors like __Boost_Function__ `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.
+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]
-Note that:
-
[warning
-As with __CPP11_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 __Example__ section for more examples on the extra care needed when returning a local function closure).
-It is always safe instead to call a local function within its declaration scope.
+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 another local function.
+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=]):
@@ -182,7 +181,7 @@
[section Accessing Types (concepts, etc)]
-This library never requires to explicitly specify the type of bound variables.
+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/``)
@@ -199,10 +198,7 @@
[typeof_template]
-It is best to use the [macroref BOOST_LOCAL_FUNCTION_TYPEOF] macro instead of using __Boost_Typeof__ so 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 (see below), in which case using this macro will not use __Boost_Typeof__ at all.
+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
@@ -212,9 +208,9 @@
[endsect]
-[section Specifying Types]
+[section Specifying Types (no Boost.Typeof)]
-While not required, it is possible to explicitly specify the type of a bound variable so the library will not internally use __Boost_Typeof__ to automatically deduce such a type.
+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.
@@ -232,29 +228,28 @@
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 usual, the result type can always be `void` to declare a function returning nothing (so `return void` is allowed when the result type is specified as one of the macro parameters).
+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, we specify bound variables, function parameters, and result type in this order because this is the order used by __CPP11_lambda__ functions.
+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 (facilitating maintenance).
+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
-Unfortunately, even when all bound variables and result types are explicitly specified, the currently library implementation still has to use __Boost_Typeof__ once (to deduce the local function object type, see the __Implementation__ section).
+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 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.
+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/``) {
@@ -263,20 +258,20 @@
When inlining a local function, note the following:
-* On __CPP03__ compliant compilers, inlined local functions always have a run-time comparable to their equivalent implementation that uses local functors (see the __Alternatives__ section).
-However, inlined 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 __CPP11__ compilers, `inline` has no effect because this library will automatically generate code that uses __CPP11__ specific features to inline the local function calls whenever possible even if the local function is not declared inline.
-Furthermore, non __CPP11__ local functions can always be passes as template parameters even when they are declared inline.
+* 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, inlined 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 __CPP03__ but it is not needed on __CPP11__ (see __N2657__) thus this library automatically generates local function calls that can be inlined on __CPP11__ compilers (even when the local function is not declared inline).
+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 __CPP03__ compliant code (because in all other cases this library will automatically take advantage of __CPP11__ features to optimize the local function calls while always allowing to pass the local function as a template parameter).
+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=]):
@@ -288,7 +283,7 @@
[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 "keyword" `recursive` (thus `recursive` cannot be used as a local function name):
+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.
@@ -298,27 +293,32 @@
[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 as in `BOOST_LOCAL_FUNCTION_NAME(inline recursive 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)
-[warning
Recursive local functions should never be called outside their declaration scope.
-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).
[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`.
]
-This is not a limitation with respect to __CPP11_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).
+
+[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]
-It is possible to overload local functions using the `boost::overloaded_function` functor of __Boost_Functional_OverloadedFunction__ from the header =boost/functional/overloaded_function.hpp= (see the __Boost_Functional_OverloadedFunction__ documentation for details).
+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]
@@ -338,14 +338,14 @@
[endsect]
-[section Storage Classifiers (`auto` and `register`)]
+[section Storage Classifiers]
-Local function parameters support the storage classifiers as usual in __CPP03__.
+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 __CPP03__ standard and therefore supported by this library.
-However, the meaning and usage of the `auto` keyword changed in __CPP11__.
-Therefore, use the `auto` storage classifier with the usual care in order to avoid writing __CPP03__ code that might not work on __CPP11__.
+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/``
@@ -366,21 +366,23 @@
[footnote
*Rationale.*
The [macroref BOOST_LOCAL_FUNCTION] and [macroref BOOST_LOCAL_FUNCTION_TPL] macros internally use `__LINE__` to generate unique identifiers.
-Therefore, if the same macro is expanded more than on time on the same line, the generated identifiers will no longer be unique and the code will not compile.
+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 a unique local function name must be provided for each different expansion (so the is no need for a `BOOST_LOCAL_FUNCTION_NAME_ID` 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 the additional macro [macroref BOOST_LOCAL_FUNCTION_ID] which can be expanded multiple times on the same line as long as programmers specify a unique identifier as the macro's first parameter.
+Therefore, this library provides additional macros [macroref BOOST_LOCAL_FUNCTION_ID] and [macroref BOOST_LOCAL_FUNCTION_TPL_ID] 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`).
-The second parameter of [macroref BOOST_LOCAL_FUNCTION_ID] is `1` if the macro is used within a template (equivalent to [macroref BOOST_LOCAL_FUNCTION_TPL]), or `0` otherwise.
-Finally, [macroref BOOST_LOCAL_FUNCTION_ID] accept the local function parameter declaration list using the exact same syntax as [macroref BOOST_LOCAL_FUNCTION].
+[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_TPL_ID] 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 indicated by the example above, the [macroref BOOST_LOCAL_FUNCTION_ID] macro is especially useful when it is necessary to invoke it multiple times within a user-defined macro (because the preprocessor expands all nested macros on the same line).
+As shown by the example above, the [macroref BOOST_LOCAL_FUNCTION_ID] and [macroref BOOST_LOCAL_FUNCTION_TPL_ID] 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]
@@ -396,68 +398,68 @@
]
[
[ `export` ]
- [ No ]
+ [ 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 __CPP03__ local classes cannot be templates. ]
+ [ No. ]
+ [ This is not supported because local functions are implemented using local classes and __CXX03__ local classes cannot be templates. ]
]
[
[ `explicit` ]
- [ No ]
+ [ No. ]
[ This is not supported because local functions are not constructors. ]
]
[
[ `inline` ]
- [ Yes ]
- [ Local functions can be specified `inline` to improve the chances that __CPP03__ standard compilers can optimize the local function call run-time (but `inline` local functions cannot be passed as template parameters on __CPP03__ standard compilers, see the __Advanced_Topics__ section). ]
+ [ 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 ]
+ [ No. ]
[ This is not supported because local functions are always defined locally within the enclosing scope and together with their declarations. ]
]
[
[ `static` ]
- [ No ]
+ [ No. ]
[ This is not supported because local functions are not member functions. ]
]
[
[ `virtual` ]
- [ No ]
+ [ 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 call.
+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 ]
+ [ Yes. ]
[ This is supported (see the __Tutorial__ section). ]
]
[
[ [^/function-name/] ]
- [ Yes ]
+ [ 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 ]
+ [ 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 ]
+ [ No. ]
[ This is not supported because local functions are not member functions. ]
]
[
[ Trailing `volatile` qualifier ]
- [ No ]
+ [ No. ]
[ This is not supported because local functions are not member functions. ]
]
]
@@ -471,15 +473,19 @@
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 will not compile (see also [@../../test/operator_error.cpp =operator_error.cpp=]):
+For example, the following code does not compile (see also [@../../test/operator_error.cpp =operator_error.cpp=]):
[operator_error]
[h5 Goto]
-It is not possible to jump with a `goto` from within a local function to a label defined in the enclosing scope.
+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]
-For example, the following will not compile (see also [@../../test/goto_error.cpp =goto_error.cpp=]):
+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]
Modified: trunk/libs/local_function/doc/alternatives.qbk
==============================================================================
--- trunk/libs/local_function/doc/alternatives.qbk (original)
+++ trunk/libs/local_function/doc/alternatives.qbk 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -34,13 +34,13 @@
[
[ ['Can be defined using C++ statement syntax] ]
[ Yes.
-Plus eventual compiler errors and debugging follow the usual format of C++ statement errors. ]
+Plus eventual compiler errors and debugging retain their usual meaning and format. ]
[ Yes.
-Plus eventual compiler errors and debugging follow the usual format of C++ statement errors. ]
+Plus eventual compiler errors and debugging retain their usual meaning and format. ]
[ Yes.
-Plus eventual compiler errors and debugging follow the usual format of C++ statement errors. ]
+Plus eventual compiler errors and debugging retain their usual meaning and format. ]
[ Yes.
-Plus eventual compiler errors and debugging follow the usual format of C++ statement errors. ]
+Plus eventual compiler errors and debugging retain their usual meaning and format. ]
[ No (it uses C++ __expression_template__ syntax). ]
]
[
@@ -54,19 +54,19 @@
[
[ ['Can be passed as template parameter (e.g., to STL algorithms)] ]
[ Yes.
-The __CPP03__ standard does not allow to pass local types as template parameters (see __N2657__) but this library implements a "trick" to get around this limitation (see the __Implementation__ section). ]
+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 __CPP03__ compilers (but yes on __CPP11__ compilers and some compilers like MSVC 8.0, see __N2657__). ]
+ [ 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). ]
+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 and non-constant value (see below). ]
+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.
@@ -75,9 +75,9 @@
Variables in scope are accessible as usual within expressions (plus `boost::phoenix::let` can be used to bind variables by constant reference). ]
]
[
- [ ['[@http://en.wikipedia.org/wiki/Type_polymorphism#Parametric_polymorphism Polymorphic] in the unbound parameter types] ]
+ [ ['[@http://en.wikipedia.org/wiki/Type_polymorphism#Parametric_polymorphism Polymorphic] in the function parameter type] ]
[ No (local functions cannot be function templates). ]
- [ No (__CPP11__ lambdas cannot be function templates). ]
+ [ No (__CXX11__ lambdas cannot be function templates). ]
[ No (local classes cannot have member function templates). ]
[ Yes. ]
[ Yes. ]
@@ -86,32 +86,32 @@
[*C++11 Lambda Function]
-__CPP11_lambda__ functions have most of the features of this library (see also the example in the __Introduction__ section):
+__CXX11_lambda_functions__ have most of the features of this library plus some additional feature (see also the example in the __Introduction__ section):
-* __CPP11_lambda__ functions can be defined within expressions while this library local functions can only be defined at declaration scope.
-* __CPP11_lambda__ functions are only supported by the __CPP11__ standard so they are not supported by all C++ compilers.
-This library local functions can be programmed also on __CPP03__ compilers (and they have performances comparable to __CPP11_lambda__ functions on __CPP11__ compilers).
-* __CPP11_lambda__ functions do not allow to bind variables in scope by constant reference or by non-constant value.
-Because a variable cannot be bound by constant reference, __CPP11_lambda__ functions can bind a variable by constant only if the variable is `CopyConstructible` and the binding requires a (potentially expensive) extra copy operation.
-Both constant reference and non-constant value binding are instead supported by this library.
-However, __CPP11_lambda__ functions provide a short-hand syntax to bind all variables in scope at once (`&` or `=`).
+* __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_lambda_error.cpp =noncopyable_lambda_error.cpp=] and [@../../example/noncopyable_local_function.cpp =noncopyable_local_function.cpp=]):
+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] [Boost.LocalFunction] ]
- [ [[noncopyable_lambda_error]] [[noncopyable_local_function]] ]
+ [ [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_lambda.cpp =expensive_copy_lambda.cpp=] and [@../../example/expensive_copy_local_function.cpp =expensive_copy_local_function.cpp=]):
+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] [Boost.LocalFunction] ]
- [ [[expensive_copy_lambda]] [[expensive_copy_local_function]] ]
+ [ [C++11 Lambda Function] [Boost.LocalFunction] ]
+ [ [[expensive_copy_cxx11_lambda]] [[expensive_copy_local_function]] ]
]
-When constant binding functionality is needed for __CPP11_lambda__ functions, the best alternative might be to bind an extra local variable declared constant and initialized to the original variable (for example, `const decltype(x)& const_x = x` and then bind `const_x` instead of `x` to the lambda function).
-In many cases the use of an extra constant variable `const_x` can be acceptable but in other cases (e.g., /constant blocks/ presented in the __Examples__ section) it might be preferable to maintain the same variable name `x` within the function body.
+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]
@@ -147,27 +147,27 @@
[h5 Performances]
-The following tables compare run-times, compile-times, and binary sizes for the different alternatives presented here for local functions.
+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 __CPP03__ compilers were measured to be larger than other approaches when compiler optimization is enabled (using `bjam release ...`).
-However, on compilers that allow to pass local types as template parameters (e.g., MSVC 8.0 or GCC 4.5.3 with __CPP11__ features enabled [^-std=c++0x], see also __N2657__) this library automatically generates optimized code that runs as fast as the fastest of the other approaches (see the "Boost.LocalFunction" approach below).
+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__) 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`).
+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 __CPP03__ compliant compilers (e.g., GCC 4.5.3 without [^-std=c++0x]) this library needs to use a function pointer in order to pass the local function class as a template parameter (see __N2657__ and the __Implementation__ section).
+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 __CPP11__ features enabled [^-std=c++0x]) because this library does not have to use the extra function pointer to implement the local function call (it directly passes the local class type as template parameter).
+This run-time performance cost 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 __CPP03__ compilers might or might not be an issue depending on the performance requirements of specific applications.
+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 compilers from inlining functor objects also other approaches like __Boost_Phoenix__ /could/ start to show higher run-times even when optimization is enabled).
+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:
@@ -197,13 +197,13 @@
[[@../../example/profile_local_function_inline.cpp =profile_local_function_inline.cpp=]]
]
[
- [[$../../example/profile_legend_lambda.png]]
- [__CPP11__ Lambda Function
+ [[$../../example/profile_legend_cxx11_lambda.png]]
+ [__CXX11__ Lambda Function
[footnote
-Measurements available only for __CPP11__ compilers.
+Measurements available only for __CXX11__ compilers.
]
]
- [[@../../example/profile_lambda.cpp =profile_lambda.cpp=]]
+ [[@../../example/profile_cxx11_lambda.cpp =profile_cxx11_lambda.cpp=]]
]
[
[[$../../example/profile_legend_local_functor.png]]
@@ -223,7 +223,7 @@
]
[table
- [ [GCC 4.5.3 With C++11 Lambdas and "Local Types as Template Parameters" ([^bjam cxxflags=-std=c++0x ...])] ]
+ [ [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]]
@@ -235,7 +235,7 @@
]
[table
- [ [MSVC 8.0 With "Local Types as Template Parameters" (Without __CPP11__ Lambdas)] ]
+ [ [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]]
@@ -247,7 +247,7 @@
]
[table
- [ [GCC 4.3.4 With __CPP03__ Only (Without __CPP11__ Lambdas and Without "Local Types as Template Parameters")] ]
+ [ [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]]
Modified: trunk/libs/local_function/doc/examples.qbk
==============================================================================
--- trunk/libs/local_function/doc/examples.qbk (original)
+++ trunk/libs/local_function/doc/examples.qbk 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -11,26 +11,30 @@
[section GCC Lambdas (without C++11)]
-Combing local functions with the [@http://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html statement expression] extension of GCC compilers, it is possible to implement lambda functions for GCC compilers even without __CPP11__ support.
+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 the statement expression GCC extension or that support __CPP11_lambda__ functions.
+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_lambda_cxx11.cpp =gcc_lambda_cxx11.cpp=]):
+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_lambda_cxx11]] ]
+ [ [[gcc_lambda]] [[gcc_cxx11_lambda]] ]
]
-Where the macros are defined in [@../../example/gcc_lambda.hpp =gcc_lambda.hpp=].
+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 __CPP11_lambda__ functions in which case the implementation uses native lambdas instead of local functions in statement expressions.
-However, __CPP11_lambda__ functions do not support constant binding so it is best to only use `const bind variable` (same as __CPP11_lambda__ `=variable`) and `bind& variable` (same as __CPP11_lambda__ `&variable`) because these have the exact same semantic between the local function and native lambda implementation.
-Unfortunately, the __CPP11_lambda__ short-hand binds `&` and `=` (which automatically bind all variables in scope either by reference or value) are not supported by the macros because they are not supported by the local function implementation.
-Finally, the result type `return `[^['result-type]] is optional and it is assumed `void` when it is not specified (same as with __CPP11_lambda__ functions).
+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]
@@ -45,7 +49,7 @@
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 idea of a /const-block/ which could be used to wrap the assertion above and catch the programming error at compile-time.
+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
@@ -58,17 +62,25 @@
``] ]
]
-Where the macros are defined in [@../../example/const_block.hpp =const_block.hpp=].
+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 which is called immediately after it is defined.
+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 __CPP11_lambda__ functions because these do not support constant binding (of course it is always possible to introduce extra constant variables `const int& const_x = x`, etc and use these variables in the assertion).
-Variables bound by value using __CPP11_lambda__ functions (`variable`, `=variable`, and `=`) are constant but they are required to be `CopyConstructible` and they introduce potentially expensive copy operations.
+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, __CPP11_lambda__ functions would allow to bind variables also using `const& variable` (constant reference) and `const&` (all variables by constant reference).
+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]
@@ -79,29 +91,30 @@
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).
-In general, the authors recommend to use __Boost_ScopeExit__ instead of the code listed here whenever possible.
+
+[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]] [
-[pre
+ [ [[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
+ ``] ]
]
- ] ]
-]
-
-Where the macros are defined in [@../../example/scope_exit.hpp =scope_exit.hpp=].
-The scope exit macros are implemented by passing a local function when constructing an object of the following class:
+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.
@@ -121,9 +134,9 @@
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 __CPP11__).
+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 valuable option.
+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]
@@ -143,10 +156,10 @@
[section GCC Nested Functions]
-The GCC C compiler supports local functions under the name of [@http://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html nested functions].
-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 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 this library:
+The following examples are taken form the GCC nested function documentation and programmed using local functions:
[table
[ [Files] ]
@@ -159,15 +172,15 @@
[section N-Papers]
-The following examples are taken from a number of N-papers and programmed using this library.
+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__ (__CPP11_lambda__ functions): It passes a local function to the STL algorithm `std::find_if`.
+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__ (__CPP11_lambda__ functions): It binds the object in scope `this` to a local function.
+This example is adapted from __N2529__ (__CXX11_lambda_functions__): It binds the object in scope `this` to a local function.
] ]
]
Modified: trunk/libs/local_function/doc/getting_started.qbk
==============================================================================
--- trunk/libs/local_function/doc/getting_started.qbk (original)
+++ trunk/libs/local_function/doc/getting_started.qbk 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -7,7 +7,7 @@
[section:Getting_Started Getting Started]
-This section explains how programmers can setup their system to use this library.
+This section explains how to setup a system to use this library.
[section This Documentation]
@@ -18,8 +18,8 @@
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 (conceptually similar to `assert`).
-A failure of the checked condition does not abort the execution of the program, it will instead make `boost::report_errors` return a non-zero program exit code.
+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.
@@ -29,8 +29,7 @@
[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__).
-As a consequence, this library is fairly demanding on compilers' compliance with the __CXX03__ standard.
+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.
@@ -47,15 +46,15 @@
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.
-This library implementation uses a number of __Boost__ libraries among which: __Boost_Preprocessor__, __Boost_ScopeExit__, __Boost_Typeof__, __Boost_TypeTraits__, and __Boost_MPL__.
-These __Boost__ libraries must be properly installed on your system in order for this library to work.
+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 preprocessor line numbers) to make internal symbols with unique names to avoid name clashes.
+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 can be used within Boost by other libraries but they are still not part of this library public API.
+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).
Modified: trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION.html
==============================================================================
--- trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION.html (original)
+++ trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -33,18 +33,18 @@
</span>BOOST_LOCAL_FUNCTION(declarations)</pre></div>
<div class="refsect1">
-<a name="id903202"></a><h2>Description</h2>
+<a name="id859236"></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_function_name</span><span class="special">)</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 macro <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 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>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>
@@ -71,19 +71,19 @@
<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>
+</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>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>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>.</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>Note:</strong></span> This macro cannot be portably used multiple times on the same line (because on GCC and other compilers, it internally uses the line number <code class="computeroutput">__LINE__</code> to generate unique identifiers).</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_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_TYPEOF.html" title="Macro BOOST_LOCAL_FUNCTION_TYPEOF">BOOST_LOCAL_FUNCTION_TYPEOF</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_FUNC
TION_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/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="Mac
ro 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>
Modified: trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html
==============================================================================
--- trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html (original)
+++ trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX</pre></div>
<div class="refsect1">
-<a name="id904846"></a><h2>Description</h2>
+<a name="id861380"></a><h2>Description</h2>
<p>If programmers leave this configuration macro undefined, its default value is <code class="computeroutput">5</code> (increasing this number might increase compilation time). When defined by programmers, this macro must be a non-negative integer number.</p>
<p><span class="bold"><strong>Note:</strong></span> This macro specifies the maximum number of local function parameters excluding bound variables (which are instead specified by <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX">BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX</a></code>).</p>
<p><span class="bold"><strong>See:</strong></span> <a class="link" href="boost_localfunction/Tutorial.html" title="Tutorial">Tutorial</a> section, <a class="link" href="boost_localfunction/Getting_Started.html" title="Getting Started"> Getting Started</a> section, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX">BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX</a></code>. </p>
Modified: trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html
==============================================================================
--- trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html (original)
+++ trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX</pre></div>
<div class="refsect1">
-<a name="id904921"></a><h2>Description</h2>
+<a name="id861454"></a><h2>Description</h2>
<p>If programmers leave this configuration macro undefined, its default value is <code class="computeroutput">10</code> (increasing this number might increase compilation time). When defined by programmers, this macro must be a non-negative integer number.</p>
<p><span class="bold"><strong>Note:</strong></span> This macro specifies the maximum number of bound variables excluding local function parameters (which are instead specified by <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX">BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX</a></code>).</p>
<p><span class="bold"><strong>See:</strong></span> <a class="link" href="boost_localfunction/Tutorial.html" title="Tutorial">Tutorial</a> section, <a class="link" href="boost_localfunction/Getting_Started.html" title="Getting Started"> Getting Started</a> section, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX">BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX</a></code>. </p>
Modified: trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html
==============================================================================
--- trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html (original)
+++ trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -26,15 +26,27 @@
<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</p>
+<p>BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS — 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: <<a class="link" href="reference.html#header.boost.local_function.config_hpp" title="Header <boost/local_function/config.hpp>">boost/local_function/config.hpp</a>>
</span>BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS</pre></div>
<div class="refsect1">
-<a name="id904994"></a><h2>Description</h2>
-<p>Control performance optimizations. Automatically set using Boost.Config BOOST_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS if not defined by user. 0 - no optimization, 1 - optimization. </p>
+<a name="id861529"></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"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></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"><</span><span class="identifier">local_class</span><span class="special">></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>
Modified: trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_ID.html
==============================================================================
--- trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_ID.html (original)
+++ trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_ID.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -7,7 +7,7 @@
<link rel="home" href="index.html" title="Chapter 1. Boost.LocalFunction 1.0.0">
<link rel="up" href="reference.html#header.boost.local_function_hpp" title="Header <boost/local_function.hpp>">
<link rel="prev" href="BOOST_LOCAL_FUNCTION_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_TPL">
-<link rel="next" href="BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">
+<link rel="next" href="BOOST_LOCAL_FUNCTION_TPL_ID.html" title="Macro BOOST_LOCAL_FUNCTION_TPL_ID">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
@@ -20,21 +20,21 @@
</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_NAME.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+<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_TPL_ID.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 — This macro allows to expand multiple local function macros on the same line. </p>
+<p>BOOST_LOCAL_FUNCTION_ID — 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: <<a class="link" href="reference.html#header.boost.local_function_hpp" title="Header <boost/local_function.hpp>">boost/local_function.hpp</a>>
-</span>BOOST_LOCAL_FUNCTION_ID(id, within_template, declarations)</pre></div>
+</span>BOOST_LOCAL_FUNCTION_ID(id, declarations)</pre></div>
<div class="refsect1">
-<a name="id904090"></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 <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code> for more detail).</p>
+<a name="id860164"></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>
@@ -44,11 +44,7 @@
<tbody>
<tr>
<td><span class="bold"><strong><code class="computeroutput">id</code></strong></span></td>
-<td>A unique identifier token which can be catted by the preprocessor (for example <code class="computeroutput">__LINE__</code> or <code class="computeroutput">local_function_number_1_on_line_123</code>). </td>
-</tr>
-<tr>
-<td><span class="bold"><strong><code class="computeroutput">within_template</code></strong></span></td>
-<td>Specify <code class="computeroutput">1</code> when this macro is used in a type-dependant context, <code class="computeroutput">0</code> otherwise (this is equivalent to using <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_TPL">BOOST_LOCAL_FUNCTION_TPL</a></code> on separate lines). </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>
@@ -58,9 +54,10 @@
</table></div>
<p>
</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>Note:</strong></span> 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 a unique local function name must be provided for each different expansion (so the is no need for a <code class="computeroutput">BOOST_LOCAL_FUNCTION_NAME_ID</code> macro).</p>
-<p><span class="bold"><strong>See:</strong></span> <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>. </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_TPL_ID.html" title="Macro BOOST_LOCAL_FUNCTION_TPL_ID">BOOST_LOCAL_FUNCTION_TPL_ID</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_TPL_ID.html" title="Macro BOOST_LOCAL_FUNCTION_TPL_ID">BOOST_LOCAL_FUNCTION_TPL_ID</a></code>. </p>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
@@ -74,7 +71,7 @@
</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_NAME.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+<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_TPL_ID.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
Modified: trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_NAME.html
==============================================================================
--- trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_NAME.html (original)
+++ trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_NAME.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -6,7 +6,7 @@
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="Chapter 1. Boost.LocalFunction 1.0.0">
<link rel="up" href="reference.html#header.boost.local_function_hpp" title="Header <boost/local_function.hpp>">
-<link rel="prev" href="BOOST_LOCAL_FUNCTION_ID.html" title="Macro BOOST_LOCAL_FUNCTION_ID">
+<link rel="prev" href="BOOST_LOCAL_FUNCTION_TPL_ID.html" title="Macro BOOST_LOCAL_FUNCTION_TPL_ID">
<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">
@@ -20,7 +20,7 @@
</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_TPL.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_TPL_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_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>
@@ -31,18 +31,19 @@
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: <<a class="link" href="reference.html#header.boost.local_function_hpp" title="Header <boost/local_function.hpp>">boost/local_function.hpp</a>>
-</span>BOOST_LOCAL_FUNCTION_NAME(qualified_function_name)</pre></div>
+</span>BOOST_LOCAL_FUNCTION_NAME(qualified_name)</pre></div>
<div class="refsect1">
-<a name="id904287"></a><h2>Description</h2>
+<a name="id860548"></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_function_name</span><span class="special">)</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>
@@ -50,18 +51,26 @@
<col>
</colgroup>
<tbody><tr>
-<td><span class="bold"><strong><code class="computeroutput">qualified_function_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">qualified_function_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">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>
+<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): <code class="computeroutput">BOOST_LOCAL_FUNCTION_NAME(inline name)</code>. This increases the chances that the compiler will be able to inline the local function calls (thus reducing run-time). However, inlined 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 inlined 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.
</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): <code class="computeroutput">BOOST_LOCAL_FUNCTION_NAME(recursive name)</code>. This allows the local function to recursively call itself from its body (as usual in C++). However, 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: <code class="computeroutput">BOOST_LOCAL_FUNCTION(inline recursive name)</code>). Furthermore, recursive local functions should only be called within their declaration scope (otherwise the result is undefined behaviour).</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_FU
NCTION_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>. </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>
@@ -75,7 +84,7 @@
</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_TPL.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_TPL_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_TPL.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
Modified: trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_NAME_TPL.html
==============================================================================
--- trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_NAME_TPL.html (original)
+++ trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_NAME_TPL.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -26,15 +26,26 @@
<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</p>
+<p>BOOST_LOCAL_FUNCTION_NAME_TPL — 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: <<a class="link" href="reference.html#header.boost.local_function_hpp" title="Header <boost/local_function.hpp>">boost/local_function.hpp</a>>
-</span>BOOST_LOCAL_FUNCTION_NAME_TPL(qualified_function_name)</pre></div>
+</span>BOOST_LOCAL_FUNCTION_NAME_TPL(name)</pre></div>
<div class="refsect1">
-<a name="id904596"></a><h2>Description</h2>
-<p>In type-dependant context. </p>
+<a name="id860960"></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>
Modified: trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TPL.html
==============================================================================
--- trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TPL.html (original)
+++ trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TPL.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -33,18 +33,20 @@
</span>BOOST_LOCAL_FUNCTION_TPL(declarations)</pre></div>
<div class="refsect1">
-<a name="id903912"></a><h2>Description</h2>
-<p>This macro must be used instead of <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code> when declaring a local function within a template. A part from that, this macro has the exact same syntax as <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code> (see <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">BOOST_LOCAL_FUNCTION</a></code> for more information): </p>
-<pre class="programlisting"><span class="special">{</span> <span class="comment">// Some declarative context with a template.</span>
+<a name="id859948"></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</span><span class="special">(</span><span class="identifier">qualified_function_name</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">qualified_name</span><span class="special">)</span>
<span class="special">...</span>
<span class="special">}</span>
</pre>
-<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 so this macro is used to indicate to the library when the enclosing scope is a template.</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_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code>. </p>
+<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_TPL_ID.html" title="Macro BOOST_LOCAL_FUNCTION_TPL_ID">BOOST_LOCAL_FUNCTION_TPL_ID</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_TPL_ID.html" title="Macro BOOST_LOCAL_FUNCTION_TPL_ID">BOOST_LOCAL_FUNCTION_TPL_ID</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>
Modified: trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TYPEOF.html
==============================================================================
--- trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TYPEOF.html (original)
+++ trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TYPEOF.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_FUNCTION_TYPEOF(bound_variable_name)</pre></div>
<div class="refsect1">
-<a name="id904629"></a><h2>Description</h2>
+<a name="id861159"></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">
@@ -56,8 +56,8 @@
<li class="listitem"><p>Bound by constant reference 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>
</ul></div>
<p>
-This macro must be prefixed by <code class="computeroutput">typename</code> when used in a type dependant context.</p>
-<p>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>
+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>
Modified: trunk/libs/local_function/doc/html/boost_localfunction/Acknowledgments.html
==============================================================================
--- trunk/libs/local_function/doc/html/boost_localfunction/Acknowledgments.html (original)
+++ trunk/libs/local_function/doc/html/boost_localfunction/Acknowledgments.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -33,7 +33,7 @@
<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://boost.2283326.n4.nabble.com/contract-diff-n1962-tt2671482.html#none" target="_top">emulate
+ 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
@@ -71,13 +71,12 @@
section and with the profiling of the different alternatives.
</p>
<p>
- Many thanks to the library's <a href="http://lists.boost.org/boost-announce/2011/12/0340.php" target="_top">Boost
- review</a> manager: Jeffrey Lee Hellrung. Thanks also to all the people
- that submitted a (positive and negative) 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 else that commented (positively and negatively) on the library during
- its Boost review.
+ 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 Boost
Modified: trunk/libs/local_function/doc/html/boost_localfunction/Advanced_Topics.html
==============================================================================
--- trunk/libs/local_function/doc/html/boost_localfunction/Advanced_Topics.html (original)
+++ trunk/libs/local_function/doc/html/boost_localfunction/Advanced_Topics.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -36,23 +36,23 @@
<dt><span class="section">Nesting</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">Specifying
- Types</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">Inlining</span></dt>
<dt><span class="section">Recursion</span></dt>
<dt><span class="section">Overloading</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___auto__and__register__">Storage
- Classifiers (<code class="computeroutput"><span class="keyword">auto</span></code> and <code class="computeroutput"><span class="keyword">register</span></code>)</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 usages of this library (at the bottom there
- is also a list of known limitations of the library).
+ 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">
@@ -60,10 +60,9 @@
Parameters</a>
</h3></div></div></div>
<p>
- This library also allows to specify default values for the local function
- parameters. However, the usual C++ syntax for default parameters that uses
- the assignment symbol <code class="computeroutput"><span class="special">=</span></code> cannot
- be used. <sup>[<a name="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>
+ 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>
@@ -88,7 +87,7 @@
<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 syntax above (see also add_with_default.cpp
):
+ the above syntax (see also add_with_default.cpp
):
<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>
@@ -116,7 +115,7 @@
<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 Boost.Utility/IdentityType
- documentation for details). Therefore, using commas within the local function
+ 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.
@@ -161,9 +160,8 @@
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 Boost.Utility/IdentityType
- macro <code class="computeroutput"><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> from the header <code class="literal">boost/utility/identity_type.hpp</code>
- can be used to wrap a type within extra parenthesis <code class="computeroutput"><span class="special">()</span></code>
- so to overcome the problem:
+ 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"><</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">></span>
@@ -176,11 +174,12 @@
</pre>
<p>
This macro expands to an expression that evaluates (at compile-time) exactly
- to the specified type. 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
+ to the specified type (furthermore, this macro does not use variadic macros
+ so it works on any C++03
+ 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>
@@ -209,9 +208,8 @@
<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 macros
- <code class="computeroutput"><span class="identifier">BOOST_IDENTITY_TYPE</span></code> can also
- be used to overcome this issue:
+ 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>
@@ -251,7 +249,7 @@
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 be simply wrapped within an extra set
+ (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>
@@ -294,7 +292,7 @@
</h3></div></div></div>
<p>
Local functions are function objects so it is possible to assign them to
- other functors like Boost.Function
+ other functors like Boost.Function'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.
@@ -329,27 +327,25 @@
</pre>
<p>
</p>
-<p>
- Note that:
- </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 __CPP11_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
- __Example__ section for more examples on the extra care needed when returning
- a local function closure). It is always safe instead to call a local function
- within its declaration scope.
+ 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 another local function. Local
+ 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">&</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>
@@ -415,9 +411,12 @@
Types (concepts, etc)</a>
</h3></div></div></div>
<p>
- This library never requires to explicitly specify the type of bound variables.
- From within local functions, programmers can access the type of a bound variable
- using the following macro:
+ 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>
@@ -485,23 +484,15 @@
<p>
</p>
<p>
- 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>
+ 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 Boost.Typeof
- so to reduce the number of times that Boost.Typeof
- is invoked:
+ 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).
</p>
-<div class="orderedlist"><ol class="orderedlist" type="1">
-<li class="listitem">
- Either the library already internally used Boost.Typeof
- once, in which case using this macro will not use Boost.Typeof
- again.
- </li>
-<li class="listitem">
- Or, the bound variable type is explicitly specified by programmers (see
- below), in which case using this macro will not use Boost.Typeof
- at all.
- </li>
-</ol></div>
<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
@@ -510,15 +501,15 @@
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">
+<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"></a><a class="link" href="Advanced_Topics.html#boost_localfunction.Advanced_Topics.specifying_types" title="Specifying Types">Specifying
- Types</a>
+<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 a bound
- variable so the library will not internally use Boost.Typeof
- to automatically deduce such a type. When specified, the bound variable type
+ 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 <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>
@@ -551,30 +542,27 @@
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 usual, the result type can always be <code class="computeroutput"><span class="keyword">void</span></code>
- to declare a function returning nothing (so <code class="computeroutput"><span class="keyword">return</span>
+ 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 add_typed.cpp
):
- <sup>[<a name="boost_localfunction.Advanced_Topics.specifying_types.f0" href="#ftn.boost_localfunction.Advanced_Topics.specifying_types.f0" class="footnote">22</a>]</sup>
+ <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">BOOST_TYPEOF_REGISTER_TYPE</span><span class="special">(</span><span class="identifier">adder</span><span class="special">)</span> <span class="comment">// Unfortunately needed for `..._NAME` below.</span>
-
-<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>
+<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"><</span><span class="keyword">int</span><span class="special">>&</span> <span class="identifier">nums</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">int</span><span class="special">&</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">)</span> <span class="special">{</span>
- <span class="comment">// Explicitly specify bound variable and result types...</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">&)</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">-></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="comment">// ... but this still uses type-of.</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>
@@ -590,7 +578,7 @@
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 (facilitating maintenance).
+ change if a bound variable type changes (reducing maintenance).
</p>
<div class="note"><table border="0" summary="Note">
<tr>
@@ -598,10 +586,8 @@
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
- Unfortunately, even when all bound variables and result types are explicitly
- specified, the currently library implementation still has to use Boost.Typeof once (to deduce
- the local function object type, see the <a class="link" href="Implementation.html" title="Annex: Implementation">Implementation</a>
- section).
+ When all bound variable and result types are explicitly specified, the
+ library implementation will not use Boost.Typeof.
</p></td></tr>
</table></div>
</div>
@@ -610,10 +596,10 @@
<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 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 <code class="computeroutput"><span class="keyword">inline</span></code>:
+ Local functions can be declared 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 <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>
@@ -624,20 +610,23 @@
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
- On __CPP03__ compliant compilers, inlined 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, inlined local functions have the important limitation
+ On C++03
+ 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 __CPP11__ compilers, <code class="computeroutput"><span class="keyword">inline</span></code>
- has no effect because this library will automatically generate code that
- uses __CPP11__ specific features to inline the local function calls whenever
- possible even if the local function is not declared inline. Furthermore,
- non __CPP11__ 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>
+ On C++11
+ compilers, <code class="computeroutput"><span class="keyword">inline</span></code> has no
+ effect because this library will automatically generate code that uses
+ C++11 specific
+ features to inline the local function calls whenever possible even if
+ the local function is not declared inline. Furthermore, non C++11
+ 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">
@@ -647,8 +636,9 @@
</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 __CPP03__ compliant code (because in all
- other cases this library will automatically take advantage of __CPP11__
+ necessary for optimizing pure C++03
+ compliant code (because in all other cases this library will automatically
+ take advantage of C++11
features to optimize the local function calls while always allowing to
pass the local function as a template parameter).
</p></td></tr>
@@ -665,7 +655,7 @@
<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">&</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">// Inlined.</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"><</span><span class="keyword">int</span><span class="special">></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>
@@ -683,7 +673,7 @@
Local functions can be declared 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 "keyword" <code class="computeroutput"><span class="identifier">recursive</span></code>
+ 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>
@@ -720,9 +710,13 @@
</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
- as in <code class="computeroutput"><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></code>).
+ 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>
@@ -730,25 +724,27 @@
<th align="left">Warning</th>
</tr>
<tr><td align="left" valign="top"><p>
- Recursive local functions should never be called outside their declaration
- scope. 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). <sup>[<a name="boost_localfunction.Advanced_Topics.recursion.f0" href="#ftn.boost_localfunction.Advanced_Topics.recursion.f0" class="footnote">24</a>]</sup> This is not a limitation with respect to __CPP11_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).
+ 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>
- It is possible to overload local functions using the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">overloaded_function</span></code>
- functor of Boost.Functional/OverloadedFunction
- from the header <code class="literal">boost/functional/overloaded_function.hpp</code>
+ 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 Boost.Functional/OverloadedFunction
+ from the <code class="literal">boost/functional/overloaded_function.hpp</code> header
(see the Boost.Functional/OverloadedFunction
documentation for details).
</p>
@@ -759,7 +755,37 @@
(see also overload.cpp
):
</p>
<p>
- [overload]
+</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">&</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">&</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"><</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">&)</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">></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="identifier">fabs</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">-</span> <span class="number">4.44</span><span class="special">)</span> <span class="special"><</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="identifier">fabs</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">-</span> <span class="number">44.44</span><span class="special">)</span> <span class="special"><</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">
@@ -805,15 +831,15 @@
<p>
</p>
</div>
-<div class="section boost_localfunction_Advanced_Topics_storage_classifiers___auto__and__register__">
+<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___auto__and__register__"></a><a class="link" href="Advanced_Topics.html#boost_localfunction.Advanced_Topics.storage_classifiers___auto__and__register__" title="Storage Classifiers (auto and register)">Storage
- Classifiers (<code class="computeroutput"><span class="keyword">auto</span></code> and <code class="computeroutput"><span class="keyword">register</span></code>)</a>
+<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 __CPP03__.
+ Local function parameters support the storage classifiers as usual in C++03.
The <code class="computeroutput"><span class="keyword">auto</span></code> storage classifier
- is specified as: <sup>[<a name="boost_localfunction.Advanced_Topics.storage_classifiers___auto__and__register__.f0" href="#ftn.boost_localfunction.Advanced_Topics.storage_classifiers___auto__and__register__.f0" class="footnote">25</a>]</sup>
+ 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>
@@ -846,52 +872,72 @@
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 the additional 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>
+ 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_TPL_ID.html" title="Macro BOOST_LOCAL_FUNCTION_TPL_ID">BOOST_LOCAL_FUNCTION_TPL_ID</a></code>
which can be expanded multiple times on the same line as long as programmers
- specify a unique identifier as the macro's first parameter. The unique identifier
+ 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>).
- The second parameter of <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_ID.html" title="Macro BOOST_LOCAL_FUNCTION_ID">BOOST_LOCAL_FUNCTION_ID</a></code>
- is <code class="computeroutput"><span class="number">1</span></code> if the macro is used within
- a template (equivalent to <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_TPL">BOOST_LOCAL_FUNCTION_TPL</a></code>),
- or <code class="computeroutput"><span class="number">0</span></code> otherwise. Finally, <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_ID.html" title="Macro BOOST_LOCAL_FUNCTION_ID">BOOST_LOCAL_FUNCTION_ID</a></code> accept
- the local function parameter declaration list 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>.
+ <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_TPL_ID.html" title="Macro BOOST_LOCAL_FUNCTION_TPL_ID">BOOST_LOCAL_FUNCTION_TPL_ID</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 same_line.cpp
):
</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="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="number">0</span> <span class="comment">/* no TPL */</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="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="comment">/* unique ID */</span><span class="special">,</span> <span class="number">0</span> <span class="comment">/* no TPL */</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="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION_TPL_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="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_TPL_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="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
+<span class="keyword">void</span> <span class="identifier">f</span><span class="special">(</span><span class="keyword">int</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="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="number">10</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="number">10</span><span class="special">);</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 indicated 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>
- macro is especially useful when it is necessary to invoke it multiple times
- within a user-defined macro (because the preprocessor expands all nested
+ 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_TPL_ID.html" title="Macro BOOST_LOCAL_FUNCTION_TPL_ID">BOOST_LOCAL_FUNCTION_TPL_ID</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>
@@ -936,7 +982,7 @@
</td>
<td>
<p>
- No
+ No.
</p>
</td>
<td>
@@ -955,13 +1001,14 @@
</td>
<td>
<p>
- No
+ No.
</p>
</td>
<td>
<p>
This is not supported because local functions are implemented using
- local classes and __CPP03__ local classes cannot be templates.
+ local classes and C++03
+ local classes cannot be templates.
</p>
</td>
</tr>
@@ -973,7 +1020,7 @@
</td>
<td>
<p>
- No
+ No.
</p>
</td>
<td>
@@ -990,16 +1037,16 @@
</td>
<td>
<p>
- Yes
+ Yes.
</p>
</td>
<td>
<p>
Local functions can be specified <code class="computeroutput"><span class="keyword">inline</span></code>
- to improve the chances that __CPP03__ standard 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 __CPP03__
- standard compilers, see the <a class="link" href="Advanced_Topics.html" title="Advanced Topics">Advanced
+ to improve the chances that C++03
+ 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 C++03
+ compilers, see the <a class="link" href="Advanced_Topics.html" title="Advanced Topics">Advanced
Topics</a> section).
</p>
</td>
@@ -1012,7 +1059,7 @@
</td>
<td>
<p>
- No
+ No.
</p>
</td>
<td>
@@ -1030,7 +1077,7 @@
</td>
<td>
<p>
- No
+ No.
</p>
</td>
<td>
@@ -1047,7 +1094,7 @@
</td>
<td>
<p>
- No
+ No.
</p>
</td>
<td>
@@ -1065,7 +1112,7 @@
</td>
<td>
<p>
- Yes
+ Yes.
</p>
</td>
<td>
@@ -1083,7 +1130,7 @@
</td>
<td>
<p>
- Yes
+ Yes.
</p>
</td>
<td>
@@ -1103,7 +1150,7 @@
</td>
<td>
<p>
- Yes
+ Yes.
</p>
</td>
<td>
@@ -1125,7 +1172,7 @@
</td>
<td>
<p>
- No
+ No.
</p>
</td>
<td>
@@ -1143,7 +1190,7 @@
</td>
<td>
<p>
- No
+ No.
</p>
</td>
<td>
@@ -1160,7 +1207,7 @@
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 call.
+ to dynamic binding or base function calls.
</p></div></td></tr></tbody>
</table></div>
<h6>
@@ -1169,29 +1216,16 @@
</h6>
<p>
Local functions cannot be operators. Naming a local function <code class="computeroutput"><span class="keyword">operator</span><span class="special">...</span></code>
- will generate a compile-time error. <sup>[<a name="boost_localfunction.Advanced_Topics.limitations__operators__etc_.f1" href="#ftn.boost_localfunction.Advanced_Topics.limitations__operators__etc_.f1" class="footnote">27</a>]</sup>
+ 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 will not compile (see also operator_error.cpp
):
+ For example, the following code does not compile (see also operator_error.cpp
):
</p>
<p>
</p>
-<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">point</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="identifier">BOOST_TYPEOF_REGISTER_TYPE</span><span class="special">(</span><span class="identifier">point</span><span class="special">)</span> <span class="comment">// Register for `NAME` 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="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">&</span> <span class="identifier">p</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">point</span><span class="special">&</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">&&</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>
-
- <span class="identifier">point</span> <span class="identifier">a</span><span class="special">;</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">x</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span> <span class="identifier">a</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">point</span> <span class="identifier">b</span> <span class="special">=</span> <span class="identifier">a</span><span class="special">;</span>
- <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">a</span> <span class="special">==</span> <span class="identifier">b</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 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">&</span> <span class="identifier">p</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">point</span><span class="special">&</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">&&</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>
@@ -1200,17 +1234,35 @@
<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>
</h6>
<p>
- It is not possible to jump with a <code class="computeroutput"><span class="keyword">goto</span></code>
- from within a local function to a label defined in the enclosing scope.
+ 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 goto.cpp
):
+ </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">></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>
- For example, the following will not compile (see also goto_error.cpp
):
+ 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 goto_error.cpp
):
</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">x</span><span class="special">)</span> <span class="special">{</span>
- <span class="keyword">if</span><span class="special">(</span><span class="identifier">x</span> <span class="special"><=</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">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"><=</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>
@@ -1233,7 +1285,7 @@
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
- then to count the number of default values to provide the correct set of
+ 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
@@ -1246,7 +1298,8 @@
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.
+ 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
@@ -1268,10 +1321,11 @@
<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 Boost.TypeTraits
naming conventions for function traits.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.Advanced_Topics.specifying_types.f0" href="#boost_localfunction.Advanced_Topics.specifying_types.f0" class="para">22</a>] </sup>
- In the examples of this documentation, we specify bound variables, function
- parameters, and result type in this order because this is the order used
- by __CPP11_lambda__ functions. However, the library accepts bound variables,
+<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>
@@ -1280,47 +1334,58 @@
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,
- inlined local functions do not use such indirect function pointer call
+ 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 __CPP03__ but it is not needed on __CPP11__ (see
- [N2657])
+ call is needed on C++03
+ but it is not needed on C++11
+ (see [N2657]
+ and Boost.Config'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 inlined on __CPP11__ compilers (even when the local function
- is not declared inline).
+ can be inline on C++11
+ 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___auto__and__register__.f0" href="#boost_localfunction.Advanced_Topics.storage_classifiers___auto__and__register__.f0" class="para">25</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 __CPP03__ 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 __CPP11__. Therefore, use the <code class="computeroutput"><span class="keyword">auto</span></code>
- storage classifier with the usual care in order to avoid writing __CPP03__
- code that might not work on __CPP11__.
+ is part of the C++03
+ 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 C++11.
+ Therefore, use the <code class="computeroutput"><span class="keyword">auto</span></code> storage
+ classifier with the usual care in order to avoid writing C++03
+ code that might not work on C++11.
</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 the same macro is expanded
+ 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 a unique
- local function name must be provided for each different expansion (so the
- is no need for a <code class="computeroutput"><span class="identifier">BOOST_LOCAL_FUNCTION_NAME_ID</span></code>
+ 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.limitations__operators__etc_.f1" href="#boost_localfunction.Advanced_Topics.limitations__operators__etc_.f1" class="para">27</a>] </sup>
+<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
Modified: trunk/libs/local_function/doc/html/boost_localfunction/Alternatives.html
==============================================================================
--- trunk/libs/local_function/doc/html/boost_localfunction/Alternatives.html (original)
+++ trunk/libs/local_function/doc/html/boost_localfunction/Alternatives.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -120,26 +120,26 @@
</td>
<td>
<p>
- Yes. Plus eventual compiler errors and debugging follow the usual
- format of C++ statement errors.
+ Yes. Plus eventual compiler errors and debugging retain their usual
+ meaning and format.
</p>
</td>
<td>
<p>
- Yes. Plus eventual compiler errors and debugging follow the usual
- format of C++ statement errors.
+ Yes. Plus eventual compiler errors and debugging retain their usual
+ meaning and format.
</p>
</td>
<td>
<p>
- Yes. Plus eventual compiler errors and debugging follow the usual
- format of C++ statement errors.
+ Yes. Plus eventual compiler errors and debugging retain their usual
+ meaning and format.
</p>
</td>
<td>
<p>
- Yes. Plus eventual compiler errors and debugging follow the usual
- format of C++ statement errors.
+ Yes. Plus eventual compiler errors and debugging retain their usual
+ meaning and format.
</p>
</td>
<td>
@@ -189,8 +189,9 @@
</td>
<td>
<p>
- Yes. The __CPP03__ standard does not allow to pass local types as
- template parameters (see [N2657])
+ Yes. The C++03
+ 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 <a class="link" href="Implementation.html" title="Annex: Implementation">Implementation</a>
section).
@@ -203,8 +204,9 @@
</td>
<td>
<p>
- No on __CPP03__ compilers (but yes on __CPP11__ compilers and some
- compilers like MSVC 8.0, see [N2657]).
+ No on C++03
+ compilers (but yes on C++11
+ compilers and some compilers like MSVC 8.0, see [N2657]).
</p>
</td>
<td>
@@ -229,7 +231,7 @@
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).
+ can also be bound using <code class="computeroutput"><span class="identifier">this_</span></code>).
</p>
</td>
<td>
@@ -239,7 +241,7 @@
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
- and non-constant value (see below).
+ (see below).
</p>
</td>
<td>
@@ -266,7 +268,7 @@
<td>
<p>
<span class="emphasis"><em>Polymorphic
- in the unbound parameter types</em></span>
+ in the function parameter type</em></span>
</p>
</td>
<td>
@@ -276,7 +278,8 @@
</td>
<td>
<p>
- No (__CPP11__ lambdas cannot be function templates).
+ No (C++11
+ lambdas cannot be function templates).
</p>
</td>
<td>
@@ -301,35 +304,53 @@
<span class="bold"><strong>C++11 Lambda Function</strong></span>
</p>
<p>
- __CPP11_lambda__ functions have most of the features of this library (see also
- the example in the <a class="link" href="../index.html#boost_localfunction.Introduction" title="Introduction">Introduction</a>
+ <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">
- __CPP11_lambda__ functions can be defined within expressions while this
- library local functions can only be defined at declaration scope.
+ <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">
- __CPP11_lambda__ functions are only supported by the __CPP11__ standard
- so they are not supported by all C++ compilers. This library local functions
- can be programmed also on __CPP03__ compilers (and they have performances
- comparable to __CPP11_lambda__ functions on __CPP11__ compilers).
+ <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 C++11
+ standard so they are not supported by all C++ compilers. This library local
+ functions can be programmed also on C++03
+ compilers (and they have performances comparable to <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
+ lambda functions</a> on C++11
+ compilers).
</li>
<li class="listitem">
- __CPP11_lambda__ functions do not allow to bind variables in scope by constant
- reference or by non-constant value. Because a variable cannot be bound
- by constant reference, __CPP11_lambda__ functions can bind a variable by
- constant only if the variable is <code class="computeroutput"><span class="identifier">CopyConstructible</span></code>
- and the binding requires a (potentially expensive) extra copy operation.
- Both constant reference and non-constant value binding are instead supported
- by this library. However, __CPP11_lambda__ functions provide a short-hand
- syntax to bind all variables in scope at once (<code class="computeroutput"><span class="special">&</span></code>
- or <code class="computeroutput"><span class="special">=</span></code>).
+ <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">&</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 noncopyable_lambda_error.cpp
+ For example, for non-copyable objects (see also noncopyable_cxx11_lambda_error.cpp
and noncopyable_local_function.cpp
):
</p>
<div class="informaltable"><table class="table">
@@ -340,7 +361,7 @@
<thead><tr>
<th>
<p>
- C++11 Lambda
+ C++11 Lambda Function
</p>
</th>
<th>
@@ -358,6 +379,7 @@
<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>
@@ -381,7 +403,7 @@
<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& x` below.</span>
-<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> <span class="special">{</span>
+<span class="keyword">int</span> <span class="identifier">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">&</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// OK: No copy</span>
@@ -398,15 +420,18 @@
</tr></tbody>
</table></div>
<p>
- Or, for objects with expensive copy operations (see also expensive_copy_lambda.cpp
+ Or, for objects with expensive copy operations (see also expensive_copy_cxx11_lambda.cpp
and expensive_copy_local_function.cpp
):
</p>
<div class="informaltable"><table class="table">
-<colgroup><col></colgroup>
+<colgroup>
+<col>
+<col>
+</colgroup>
<thead><tr>
<th>
<p>
- C++11 Lambda
+ C++11 Lambda Function
</p>
</th>
<th>
@@ -415,31 +440,68 @@
</p>
</th>
</tr></thead>
-<tbody>
-<tr><td>
+<tbody><tr>
+<td>
<p>
- [expensive_copy_lambda
+</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">&</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"><</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"><<</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 `&x` then `x` is not constant.</span>
+ <span class="special">};</span>
+ <span class="identifier">f</span><span class="special">();</span>
+
+ <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
</p>
- </td></tr>
-<tr><td>
+ </td>
+<td>
<p>
- expensive_copy_local_function
+</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">&</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"><</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"><<</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& 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">&</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>
+ </td>
+</tr></tbody>
</table></div>
<p>
- ]
- </p>
-<p>
- When constant binding functionality is needed for __CPP11_lambda__ functions,
- the best alternative might be to bind an extra local variable declared constant
- and initialized to the original variable (for example, <code class="computeroutput"><span class="keyword">const</span>
- <span class="identifier">decltype</span><span class="special">(</span><span class="identifier">x</span><span class="special">)&</span> <span class="identifier">const_x</span> <span class="special">=</span> <span class="identifier">x</span></code> and then bind <code class="computeroutput"><span class="identifier">const_x</span></code>
- instead of <code class="computeroutput"><span class="identifier">x</span></code> to the lambda
- function). In many cases the use of an extra constant variable <code class="computeroutput"><span class="identifier">const_x</span></code> can be acceptable but in other cases
- (e.g., <span class="emphasis"><em>constant blocks</em></span> presented in the <a class="link" href="Examples.html" title="Examples">Examples</a>
- section) it might be preferable to maintain the same variable name <code class="computeroutput"><span class="identifier">x</span></code> within the function body.
+ 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>
@@ -479,6 +541,7 @@
<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">&</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>
@@ -510,7 +573,7 @@
<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="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>
@@ -555,6 +618,7 @@
<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">&</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>
@@ -590,7 +654,7 @@
<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="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>
@@ -669,7 +733,7 @@
<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="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>
@@ -690,23 +754,26 @@
</h6>
<p>
The following tables compare run-times, compile-times, and binary sizes for
- the different alternatives presented here for local functions.
+ 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 __CPP03__ compilers
- were measured to be larger than other approaches when compiler optimization
+ to the ones of the other approaches. This library run-times on C++03
+ 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
- __CPP11__ features enabled <code class="literal">-std=c++0x</code>, see also [N2657])
+ C++11 features
+ enabled <code class="literal">-std=c++0x</code>, see also [N2657]
+ and Boost.Config'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 [N2657])
+ cannot be portably passed as template parameter (see [N2657]
+ and Boost.Config'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>).
@@ -721,9 +788,10 @@
</tr>
<tr><td align="left" valign="top"><p>
The run-time performances of this library local functions are explained because
- on __CPP03__ compliant compilers (e.g., GCC 4.5.3 without <code class="literal">-std=c++0x</code>)
- this library needs to use a function pointer in order to pass the local function
- class as a template parameter (see [N2657]
+ on C++03
+ 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 [N2657]
and the <a class="link" href="Implementation.html" title="Annex: Implementation">Implementation</a>
section). For all tested compilers, this function pointer prevents the compiler
optimization algorithms from inlining the local function calls. Instead,
@@ -731,19 +799,22 @@
have been observed to allow all tested compilers to inline all the function
calls for optimization. This run-time performance cost is not present on
compilers that allow to pass local types as template parameters (e.g., MSVC
- 8.0 or GCC 4.5.3 with __CPP11__ features enabled <code class="literal">-std=c++0x</code>)
+ 8.0 or GCC 4.5.3 with C++11
+ features enabled <code class="literal">-std=c++0x</code>, see Boost.Config'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 __CPP03__ 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.
+ This run-time performance cost on C++03
+ 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
@@ -752,8 +823,10 @@
will perform with respect to each other when a more complex set of instructions
is programmed for the local function body (e.g., <span class="emphasis"><em>if</em></span> a
more complex set of instructions in the local function body were to inhibit
- some compilers from inlining functor objects also other approaches like Boost.Phoenix <span class="emphasis"><em>could</em></span>
- start to show higher run-times even when optimization is enabled).
+ 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 Boost.Phoenix
+ <span class="emphasis"><em>could</em></span> start to show higher run-times even when optimization
+ is enabled).
</p>
<p>
The following commands were executed from the library example directory to
@@ -832,17 +905,18 @@
<tr>
<td>
<p>
- <span class="inlinemediaobject"><img src="../../../example/profile_legend_lambda.png" alt="profile_legend_lambda"></span>
+ <span class="inlinemediaobject"><img src="../../../example/profile_legend_cxx11_lambda.png" alt="profile_legend_cxx11_lambda"></span>
</p>
</td>
<td>
<p>
- __CPP11__ Lambda Function <sup>[<a name="boost_localfunction.Alternatives.f0" href="#ftn.boost_localfunction.Alternatives.f0" class="footnote">a</a>]</sup>
+ C++11
+ Lambda Function <sup>[<a name="boost_localfunction.Alternatives.f0" href="#ftn.boost_localfunction.Alternatives.f0" class="footnote">a</a>]</sup>
</p>
</td>
<td>
<p>
- profile_lambda.cpp
+ profile_cxx11_lambda.cpp
</p>
</td>
</tr>
@@ -899,15 +973,16 @@
</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 __CPP11__ compilers.
+ Measurements available only for C++11
+ 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 Lambdas and "Local Types as Template Parameters"
- (<code class="literal">bjam cxxflags=-std=c++0x ...</code>)
+ 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>
@@ -931,8 +1006,8 @@
<colgroup><col></colgroup>
<thead><tr><th>
<p>
- MSVC 8.0 With "Local Types as Template Parameters" (Without
- __CPP11__ Lambdas)
+ MSVC 8.0 With "Local Classes as Template Parameters" (Without
+ C++11 Lambda Functions)
</p>
</th></tr></thead>
<tbody>
@@ -955,8 +1030,9 @@
<colgroup><col></colgroup>
<thead><tr><th>
<p>
- GCC 4.3.4 With __CPP03__ Only (Without __CPP11__ Lambdas and Without
- "Local Types as Template Parameters")
+ GCC 4.3.4 With C++03
+ Only (Without C++11
+ Lambda Functions and Without "Local Classes as Template Parameters")
</p>
</th></tr></thead>
<tbody>
Modified: trunk/libs/local_function/doc/html/boost_localfunction/Examples.html
==============================================================================
--- trunk/libs/local_function/doc/html/boost_localfunction/Examples.html (original)
+++ trunk/libs/local_function/doc/html/boost_localfunction/Examples.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -48,9 +48,10 @@
Lambdas (without C++11)</a>
</h3></div></div></div>
<p>
- Combing local functions with the <a href="http://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html" target="_top">statement
- expression</a> extension of GCC compilers, it is possible to implement
- lambda functions for GCC compilers even without __CPP11__ support.
+ 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 C++11
+ support.
</p>
<div class="warning"><table border="0" summary="Warning">
<tr>
@@ -58,13 +59,14 @@
<th align="left">Warning</th>
</tr>
<tr><td align="left" valign="top"><p>
- This code only works on compilers that support the statement expression
- GCC extension or that support __CPP11_lambda__ functions.
+ 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 gcc_lambda.cpp
- and gcc_lambda_cxx11.cpp
):
+ and gcc_cxx11_lambda.cpp
):
</p>
<div class="informaltable"><table class="table">
<colgroup>
@@ -102,35 +104,80 @@
</td>
<td>
<p>
- [gcc_lambda_cxx11
+</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">-></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 gcc_lambda.hpp
):
</p>
<p>
- Where the macros are defined in gcc_lambda.hpp
.
+</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 __CPP11_lambda__
- functions in which case the implementation uses native lambdas instead of
- local functions in statement expressions. However, __CPP11_lambda__ functions
- 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 __CPP11_lambda__ <code class="computeroutput"><span class="special">=</span><span class="identifier">variable</span></code>) and <code class="computeroutput"><span class="identifier">bind</span><span class="special">&</span> <span class="identifier">variable</span></code>
- (same as __CPP11_lambda__ <code class="computeroutput"><span class="special">&</span><span class="identifier">variable</span></code>) because these have the exact
- same semantic between the local function and native lambda implementation.
- Unfortunately, the __CPP11_lambda__ short-hand binds <code class="computeroutput"><span class="special">&</span></code>
- and <code class="computeroutput"><span class="special">=</span></code> (which automatically bind
- all variables in scope either by reference or value) are not supported by
- the macros because they are not supported by the local function implementation.
- 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>
+ 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">&</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>') 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">&</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 __CPP11_lambda__ functions).
+ 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">
@@ -156,9 +203,10 @@
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 idea 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>
+ 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
@@ -207,30 +255,70 @@
</tr></tbody>
</table></div>
<p>
- Where the macros are defined in const_block.hpp
.
+ The constant block macros are implemented using local functions (see also
+ const_block.hpp
):
+ </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">&</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 which is
+ 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 __CPP11_lambda__
- functions because these do not support constant binding (of course it is
- always possible to introduce extra constant variables <code class="computeroutput"><span class="keyword">const</span>
- <span class="keyword">int</span><span class="special">&</span>
- <span class="identifier">const_x</span> <span class="special">=</span>
- <span class="identifier">x</span></code>, etc and use these variables
- in the assertion). Variables bound by value using __CPP11_lambda__ functions
- (<code class="computeroutput"><span class="identifier">variable</span></code>, <code class="computeroutput"><span class="special">=</span><span class="identifier">variable</span></code>,
+ 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">28</a>]</sup>
+ 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">)&</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">)&</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">[&</span><span class="identifier">const_x</span><span class="special">,</span> <span class="special">&</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">
@@ -250,9 +338,20 @@
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 Boost.ScopeExit
- as well). In general, the authors recommend to use Boost.ScopeExit
- instead of the code listed here whenever possible.
+ 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 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).
+ </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
@@ -292,22 +391,23 @@
</p>
</td>
<td>
-<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting">person& p = persons_.back();
- person::evolution_t checkpoint = p.evolution_;
+ <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">&</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>
- BOOST_SCOPE_EXIT(checkpoint, &p, this_) { // Or extra variable <code class="computeroutput"><span class="identifier">const_p</span></code>.
- if (checkpoint == p.evolution_) this_->persons_.pop_back();
- } BOOST_SCOPE_EXIT_END
+<span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">(</span><span class="identifier">checkpoint</span><span class="special">,</span> <span class="special">&</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">-></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>
- Where the macros are defined in scope_exit.hpp
.
- </p>
-<p>
The scope exit macros are implemented by passing a local function when constructing
- an object of the following class:
+ an object of the following class (see also scope_exit.hpp
):
</p>
<p>
</p>
@@ -321,6 +421,22 @@
<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.
@@ -416,9 +532,9 @@
<p>
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. <sup>[<a name="boost_localfunction.Examples.boost_phoenix_functions.f0" href="#ftn.boost_localfunction.Examples.boost_phoenix_functions.f0" class="footnote">29</a>]</sup> Therefore, in many cases creating the Boost.Phoenix
+ 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 Boost.Phoenix
function from global functors (possibly with the help of Boost.Phoenix
- adaptor macros) might be a more valuable option.
+ adaptor macros) might be a more useful.
</p>
</div>
<div class="section boost_localfunction_Examples_closures">
@@ -468,15 +584,16 @@
Nested Functions</a>
</h3></div></div></div>
<p>
- The GCC C compiler supports local functions under the name of <a href="http://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html" target="_top">nested
- functions</a>. Nested functions are exclusively a C extension of the
- GCC compiler (they are not supported for C++ not even by the GCC compiler,
+ 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 this library:
+ and programmed using local functions:
</p>
<div class="informaltable"><table class="table">
<colgroup><col></colgroup>
@@ -509,8 +626,8 @@
<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 a number of N-papers and programmed
- using this library.
+ The following examples are taken from different C++ "N-papers"
+ and programmed using local functions:
</p>
<div class="informaltable"><table class="table">
<colgroup>
@@ -539,8 +656,9 @@
<td>
<p>
This example is adapted from [N2550]
- (__CPP11_lambda__ functions): 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>.
+ (<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>
@@ -553,7 +671,8 @@
<td>
<p>
This example is adapted from [N2529]
- (__CPP11_lambda__ functions): It binds the object in scope <code class="computeroutput"><span class="keyword">this</span></code> to a local function.
+ (<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>
@@ -562,17 +681,15 @@
</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">28</a>] </sup>
- Ideally, __CPP11_lambda__ functions would allow to bind variables also
- using <code class="computeroutput"><span class="keyword">const</span><span class="special">&</span>
- <span class="identifier">variable</span></code> (constant reference)
- and <code class="computeroutput"><span class="keyword">const</span><span class="special">&</span></code>
+<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">&</span> <span class="identifier">variable</span></code> (constant reference) and <code class="computeroutput"><span class="keyword">const</span><span class="special">&</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">29</a>] </sup>
+<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 __CPP11__).
+ classes cannot be templates in C++ (not even in C++11).
</p></div>
</div>
</div>
Modified: trunk/libs/local_function/doc/html/boost_localfunction/Getting_Started.html
==============================================================================
--- trunk/libs/local_function/doc/html/boost_localfunction/Getting_Started.html (original)
+++ trunk/libs/local_function/doc/html/boost_localfunction/Getting_Started.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -34,7 +34,7 @@
<dt><span class="section">Installation</span></dt>
</dl></div>
<p>
- This section explains how programmers can setup their system to use this library.
+ 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">
@@ -59,10 +59,11 @@
<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 (conceptually similar to <code class="computeroutput"><span class="identifier">assert</span></code>).
- A failure of the checked condition does not abort the execution of the program,
- it will instead make <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>
+ 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">
@@ -74,10 +75,9 @@
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).
- As a consequence, this library is fairly demanding on compilers' compliance
- with the C++03
- standard. The authors originally developed and tested the library on:
+ 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:
</p>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
@@ -110,12 +110,14 @@
option for MSVC, etc) and they can start compiling code using this library.
</p>
<p>
- This library implementation uses a number of Boost
- libraries among which: Boost.Preprocessor,
- Boost.ScopeExit,
- Boost.Typeof, Boost.TypeTraits, and
- Boost.MPL. These Boost libraries must be properly installed
- on your system in order for this library to work.
+ The library implementation uses Boost.Typeof
+ 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 Boost.Typeof
+ 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,
@@ -157,7 +159,7 @@
<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 preprocessor line numbers) to make internal
+ 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
@@ -167,7 +169,7 @@
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 can be used within
+ 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>
Modified: trunk/libs/local_function/doc/html/boost_localfunction/Implementation.html
==============================================================================
--- trunk/libs/local_function/doc/html/boost_localfunction/Implementation.html (original)
+++ trunk/libs/local_function/doc/html/boost_localfunction/Implementation.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -49,13 +49,15 @@
</h6>
<p>
This library uses a local class to implement the local function object. However,
- in __CPP03__ 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 __CPP11__, MSVC, and some other compilers
- (see [N2657]).
+ in C++03
+ 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 C++11,
+ MSVC, and some other compilers (see [N2657]
+ and Boost.Config'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 eventual function
- default parameters):
+ "tricks" (both tricks can be extended to support function default
+ parameters):
</p>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
@@ -63,13 +65,14 @@
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).
+ 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 polymorphism.
+ is then called via dynamic binding.
</li>
</ol></div>
<p>
@@ -83,8 +86,8 @@
<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">&)):</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="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">&))</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">&</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>
@@ -108,14 +111,13 @@
<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">&</span> <span class="identifier">_sum</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">int</span><span class="special">&</span> <span class="identifier">_factor</span><span class="special">):</span>
- <span class="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">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">&</span> <span class="identifier">_sum</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">int</span><span class="special">&</span> <span class="identifier">_factor</span><span class="special">)</span>
+ <span class="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">&</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">&</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">&</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"><</span><span class="identifier">local_add</span><span class="special">*>(</span><span class="identifier">obj</span><span class="special">);</span>
<span class="identifier">self</span><span class="special">-></span><span class="identifier">body</span><span class="special">(</span><span class="identifier">self</span><span class="special">-></span><span class="identifier">sum_</span><span class="special">,</span> <span class="identifier">self</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>
@@ -147,11 +149,13 @@
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 tricks has been observed to
- allow for compiler optimizations that inline the local function calls (because
+ 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 types
- as template parameters (MSVC, __CPP11__, etc, see [N2657]),
+ virtual function respectively). Therefore, on compilers that accept local classes
+ as template parameters (MSVC, C++11,
+ etc, see [N2657]
+ and Boost.Config'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
@@ -168,9 +172,9 @@
(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 metaprogramming and specifically using the macros defined
+ 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">30</a>]</sup>
+ 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
@@ -202,7 +206,7 @@
</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">30</a>] </sup>
+<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 Contract++
syntax.
Modified: trunk/libs/local_function/doc/html/boost_localfunction/No_Variadic_Macros.html
==============================================================================
--- trunk/libs/local_function/doc/html/boost_localfunction/No_Variadic_Macros.html (original)
+++ trunk/libs/local_function/doc/html/boost_localfunction/No_Variadic_Macros.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -37,10 +37,10 @@
</h6>
<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 __CPP11__ 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
+ macros</a> (notably, these include GCC, MSVC, and all C++11
+ 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 <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>
@@ -91,17 +91,17 @@
<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="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 how the same macros accept both syntaxes on compilers with variadic macros
+ 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 parameter list is always specified using <code class="computeroutput"><span class="keyword">void</span></code>
- on compilers with and without variadic macros:
+ 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>
Modified: trunk/libs/local_function/doc/html/boost_localfunction/Release_Notes.html
==============================================================================
--- trunk/libs/local_function/doc/html/boost_localfunction/Release_Notes.html (original)
+++ trunk/libs/local_function/doc/html/boost_localfunction/Release_Notes.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -32,8 +32,8 @@
</p>
<h6>
<a name="boost_localfunction.Release_Notes.h0"></a>
- <span><a name="boost_localfunction.Release_Notes.version_1_0_0__2012_01_31_"></a></span><a class="link" href="Release_Notes.html#boost_localfunction.Release_Notes.version_1_0_0__2012_01_31_">Version
- 1.0.0 (2012-01-31)</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>
</h6>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
@@ -65,6 +65,17 @@
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>
<h6>
<a name="boost_localfunction.Release_Notes.h1"></a>
Modified: trunk/libs/local_function/doc/html/boost_localfunction/Tutorial.html
==============================================================================
--- trunk/libs/local_function/doc/html/boost_localfunction/Tutorial.html (original)
+++ trunk/libs/local_function/doc/html/boost_localfunction/Tutorial.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -34,7 +34,7 @@
<dt><span class="section">Templates</span></dt>
</dl></div>
<p>
- This section illustrates basic usages of this library.
+ 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">
@@ -43,8 +43,8 @@
<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 <boost/local_function.hpp>">boost/local_function.hpp</a></code>. The
macros must be used from within a declarative context (this is a limitation
- with respect to __CPP11_lambda__ functions which can instead be declared
- also within expressions):
+ 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"><</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">></span> <span class="comment">// This library header.</span>
@@ -65,11 +65,17 @@
which it is declared.
</p>
<p>
- The local function body is specified in a code block <code class="computeroutput"><span class="special">{</span>
- <span class="special">...</span> <span class="special">}</span></code>
- using the usual C++ syntax. The body is specified outside any of the macros
- so eventual compiler error messages and related line numbers retain their
- usual meaning and format. <sup>[<a name="boost_localfunction.Tutorial.local_functions.f1" href="#ftn.boost_localfunction.Tutorial.local_functions.f1" class="footnote">6</a>]</sup>
+ 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>
@@ -98,7 +104,7 @@
</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
+ 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>
@@ -123,29 +129,12 @@
<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, member
- variables, 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.
- <sup>[<a name="boost_localfunction.Tutorial.Binding.f0" href="#ftn.boost_localfunction.Tutorial.Binding.f0" class="footnote">8</a>]</sup>
+ 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. <sup>[<a name="boost_localfunction.Tutorial.Binding.f0" href="#ftn.boost_localfunction.Tutorial.Binding.f0" class="footnote">8</a>]</sup>
</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>
- The library implementation uses Boost.Typeof
- to automatically deduce the types of the bound variables. Therefore, in
- order to compile code in type-of emulation mode, all types should be properly
- registered with <code class="computeroutput"><span class="identifier">BOOST_TYPEOF_REGISTER_TYPE</span></code>
- or <code class="computeroutput"><span class="identifier">BOOST_TYPEOF_REGISTER_TEMPLATE</span></code>
- macros, or appropriate Boost.Typeof
- headers should be included (see the Boost.Typeof
- documentation for more detail).
- </p></td></tr>
-</table></div>
<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
@@ -189,9 +178,9 @@
by reference).
</p>
<p>
- The type of a bound variable is automatically deduced and it is the exact
- same type used to declare such a variable in the enclosing scope with the
- following notes:
+ 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:
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
@@ -202,8 +191,8 @@
. 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 __CPP11_lambda__ functions 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>
+ 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,
@@ -213,11 +202,11 @@
</li>
</ul></div>
<p>
- When a variable is bound by value (constant or not), its type must be <code class="computeroutput"><span class="identifier">CopyConstructible</span></code> (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.
+ When a variable is bound by value (constant or not), its type must be 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.
</p>
<p>
For example, let's program the local function <code class="computeroutput"><span class="identifier">add</span></code>
@@ -242,7 +231,7 @@
<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="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>
@@ -339,7 +328,7 @@
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 <code class="computeroutput"><span class="keyword">private</span></code> data member <code class="computeroutput"><span class="identifier">sum_</span></code>.
+ the private data member <code class="computeroutput"><span class="identifier">sum_</span></code>.
</p>
</div>
<div class="section boost_localfunction_Tutorial_templates">
@@ -348,7 +337,8 @@
</h3></div></div></div>
<p>
When local functions are programmed within templates, they need to be declared
- using the special macro <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_TPL">BOOST_LOCAL_FUNCTION_TPL</a></code>:
+ 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"><</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">></span> <span class="comment">// This library header.</span>
@@ -358,14 +348,16 @@
<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</span><span class="special">(</span><span class="emphasis"><em>name</em></span><span class="special">)</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>
- macro has 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>
- macro that we have seen so far.
+ 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
@@ -412,9 +404,9 @@
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 __CPP03__ 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 C99
+ <span class="bold"><strong>Rationale.</strong></span> The C++03
+ 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 C99
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.
@@ -448,8 +440,8 @@
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>)
+ 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>
@@ -473,17 +465,17 @@
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">&</span></code> (this is the same binding semantic
adopted by Boost.ScopeExit).
- On the other hand, 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">[&]</span></code>
+ 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">[&]</span></code>
is used instead of <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">[&]</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://boost.2283326.n4.nabble.com/local-this-or-this-td3423912.html" target="_top">Boost
- practises</a> which postfix with an underscore identifiers that are
- named after keywords (the C++ keyword <code class="computeroutput"><span class="keyword">this</span></code>
+ <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
@@ -502,11 +494,10 @@
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
- member variable named after the local function and local classes cannot
- have static member variables in C++) and nesting (because the argument
- binding variable must be declared as a member variable so it is visible
- in a local function nested within the body member function) -- see the
- <a class="link" href="Implementation.html" title="Annex: Implementation">Implementation</a>
+ 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.
@@ -520,12 +511,15 @@
<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 __CPP03__ does
- not allow to use <code class="computeroutput"><span class="keyword">typename</span></code>
- outside templates, the special <code class="computeroutput"><span class="identifier">TPL</span></code>
- macro is 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.
+ indicate that some expressions evaluate to a type. Because C++03
+ 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.
+ C++11 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>
Modified: trunk/libs/local_function/doc/html/index.html
==============================================================================
--- trunk/libs/local_function/doc/html/index.html (original)
+++ trunk/libs/local_function/doc/html/index.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -65,15 +65,15 @@
<dt><span class="section">Nesting</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">Specifying
- Types</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">Inlining</span></dt>
<dt><span class="section">Recursion</span></dt>
<dt><span class="section">Overloading</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___auto__and__register__">Storage
- Classifiers (<code class="computeroutput"><span class="keyword">auto</span></code> and <code class="computeroutput"><span class="keyword">register</span></code>)</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
@@ -108,18 +108,19 @@
</dl>
</div>
<p>
- This library allows to program functions locally, directly within the scope where
- they are needed.
+ 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> are a form of <span class="emphasis"><em>information hiding</em></span>
+ <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. Local functions therefore complement
+ 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 Pascal
and Ada,
@@ -129,7 +130,7 @@
<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
- the lambda functions assigning them to local variables. For example (see also
+ 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>
@@ -170,7 +171,7 @@
<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="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>
@@ -192,7 +193,7 @@
</li>
<li class="listitem">
Local functions can be passed as template parameters so they can be conveniently
- used with STL algorithms, etc. <sup>[<a name="boost_localfunction.Introduction.f0" href="#ftn.boost_localfunction.Introduction.f0" class="footnote">1</a>]</sup>
+ 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
@@ -225,7 +226,7 @@
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"><p><small>Last revised: April 10, 2012 at 22:33:23 GMT</small></p></td>
+<td align="left"><p><small>Last revised: April 13, 2012 at 00:19:19 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
Modified: trunk/libs/local_function/doc/html/reference.html
==============================================================================
--- trunk/libs/local_function/doc/html/reference.html (original)
+++ trunk/libs/local_function/doc/html/reference.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -32,14 +32,15 @@
<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 <boost/local_function.hpp></h3></div></div></div>
-<p>Local functions allow to program functions locally, directly within the scope where they are needed. </p>
+<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, within_template, declarations)
-<a class="link" href="BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a>(qualified_function_name)
-<a class="link" href="BOOST_LOCAL_FUNCTION_NAME_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_NAME_TPL">BOOST_LOCAL_FUNCTION_NAME_TPL</a>(qualified_function_name)
+<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_TPL_ID.html" title="Macro BOOST_LOCAL_FUNCTION_TPL_ID">BOOST_LOCAL_FUNCTION_TPL_ID</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">
Modified: trunk/libs/local_function/doc/implementation.qbk
==============================================================================
--- trunk/libs/local_function/doc/implementation.qbk (original)
+++ trunk/libs/local_function/doc/implementation.qbk 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -17,27 +17,27 @@
[h5 Local Classes as Template Parameters]
This library uses a local class to implement the local function object.
-However, in __CPP03__ 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 __CPP11__, MSVC, and some other compilers (see __N2657__).
-To work around this limitation, this library investigated the following two "tricks" (both tricks can be extended to support eventual function default parameters):
+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).
+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 polymorphism.
+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 tricks has been 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 types as template parameters (MSVC, __CPP11__, etc, see __N2657__), 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.
+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.
[h5 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 metaprogramming and specifically using the macros defined by the files in the =boost/local_function/detail/preprocessor/keyword/= directory.
+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.
]
Modified: trunk/libs/local_function/doc/introduction.qbk
==============================================================================
--- trunk/libs/local_function/doc/introduction.qbk (original)
+++ trunk/libs/local_function/doc/introduction.qbk 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -7,11 +7,11 @@
[section:Introduction Introduction]
-/Local 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.
-Local functions therefore complement other structuring possibilities such as namespaces and classes.
+/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 the lambda functions assigning them to local variables.
+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]
@@ -25,7 +25,7 @@
* 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, etc.
+* 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).
]
Modified: trunk/libs/local_function/doc/local_function.qbk
==============================================================================
--- trunk/libs/local_function/doc/local_function.qbk (original)
+++ trunk/libs/local_function/doc/local_function.qbk 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -38,6 +38,7 @@
[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++]]
@@ -83,15 +84,19 @@
[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/scope_exit.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]
@@ -104,7 +109,7 @@
[import ../example/impl_tparam_tricks.cpp]
[import ../example/impl_pp_keyword.cpp]
-This library allows to program functions locally, directly within the scope where they are needed.
+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]
Modified: trunk/libs/local_function/doc/no_variadic_macros.qbk
==============================================================================
--- trunk/libs/local_function/doc/no_variadic_macros.qbk (original)
+++ trunk/libs/local_function/doc/no_variadic_macros.qbk 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -11,7 +11,7 @@
[h5 Sequence Syntax]
-Most modern compilers support [@http://en.wikipedia.org/wiki/Variadic_macro variaid macros] (notably, these include GCC, MSVC, and all __CPP11__ compilers).
+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.
@@ -28,8 +28,8 @@
[add]
-Note how the same macros accept both syntaxes on compilers with variadic macros and only the sequence syntax on compilers without variadic macros.
-Finally, an parameter list is always specified using `void` on compilers with and without variadic macros:
+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]
Modified: trunk/libs/local_function/doc/release_notes.qbk
==============================================================================
--- trunk/libs/local_function/doc/release_notes.qbk (original)
+++ trunk/libs/local_function/doc/release_notes.qbk 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -9,7 +9,7 @@
This section lists the major changes between different library releases (in chronological order).
-[h5 Version 1.0.0 (2012-01-31)]
+[h5 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.
@@ -19,6 +19,9 @@
# 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.
[h5 Version 0.2.0 (2011-05-14)]
Modified: trunk/libs/local_function/doc/tutorial.qbk
==============================================================================
--- trunk/libs/local_function/doc/tutorial.qbk (original)
+++ trunk/libs/local_function/doc/tutorial.qbk 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -7,12 +7,12 @@
[section:Tutorial Tutorial]
-This section illustrates basic usages of this library.
+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 __CPP11_lambda__ functions which can instead be declared also within expressions):
+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.
@@ -33,7 +33,9 @@
]
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 body is specified in a code block `{ ... }` using the usual C++ syntax.
+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.*
@@ -50,10 +52,10 @@
[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):
+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 __CPP03__ standard does not allow to pass empty parameters to a macro so the macro cannot be invoked as `BOOST_LOCAL_FUNCTION()`.
+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.
]
@@ -67,9 +69,9 @@
[section:Binding Binding Variables]
-Variables in scope (local variables, enclosing function parameters, member variables, etc) can be bound to a local function declaration.
+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.
+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.
@@ -78,11 +80,6 @@
For example, this reduces maintenance because if a bound variable type is changed, the local function declaration does not have to change.
]
-[important
-The library implementation uses __Boost_Typeof__ to automatically deduce the types of the bound variables.
-Therefore, in order to compile code in type-of emulation mode, all types should be properly registered with `BOOST_TYPEOF_REGISTER_TYPE` or `BOOST_TYPEOF_REGISTER_TEMPLATE` macros, or appropriate __Boost_Typeof__ headers should be included (see the __Boost_Typeof__ documentation for more detail).
-]
-
This library introduces the new "keyword" `bind`
[footnote
Obviously, the token `bind` is not a keyword of the C++ language.
@@ -110,18 +107,18 @@
[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.
+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 and it is the exact same type used to declare such a variable in the enclosing scope with the following notes:
+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 __CPP11_lambda__ functions but it is supported by this library.)
+(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).
@@ -132,10 +129,10 @@
[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__).
-On the other hand, 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[&]`.
+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 `CopyConstructible` (i.e., its must provide a copy constructor).
+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.
@@ -151,7 +148,7 @@
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://boost.2283326.n4.nabble.com/local-this-or-this-td3423912.html Boost practises] which postfix with an underscore identifiers that are named after keywords (the C++ keyword `this` in this case).
+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).
]
@@ -161,7 +158,7 @@
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 member variable named after the local function and local classes cannot have static member variables in C++) and nesting (because the argument binding variable must be declared as a member variable so it is visible in a local function nested within the body member function) -- see the __Implementation__ section.
+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.
@@ -190,17 +187,19 @@
*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_`.
+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 macro [macroref BOOST_LOCAL_FUNCTION_TPL]:
+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 __CPP03__ does not allow to use `typename` outside templates, the special `TPL` macro is used to indicate that the enclosing scope is a template so this library can safely use `typename` to resolve expression type ambiguities.
+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.
@@ -210,11 +209,11 @@
...
``/result-type/`` BOOST_LOCAL_FUNCTION_TPL(``/parameters/``) {
``/body-code/``
- } BOOST_LOCAL_FUNCTION_NAME(``/name/``)
+ } BOOST_LOCAL_FUNCTION_NAME_TPL(``/name/``)
...
}
-The [macroref BOOST_LOCAL_FUNCTION_TPL] macro has the exact same syntax of the [macroref BOOST_LOCAL_FUNCTION] macro that we have seen so far.
+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=]):
Modified: trunk/libs/local_function/example/Jamfile.v2
==============================================================================
--- trunk/libs/local_function/example/Jamfile.v2 (original)
+++ trunk/libs/local_function/example/Jamfile.v2 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -18,6 +18,7 @@
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 ;
Modified: trunk/libs/local_function/example/add_global_functor.cpp
==============================================================================
--- trunk/libs/local_function/example/add_global_functor.cpp (original)
+++ trunk/libs/local_function/example/add_global_functor.cpp 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -16,6 +16,7 @@
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.
Modified: trunk/libs/local_function/example/add_local_functor.cpp
==============================================================================
--- trunk/libs/local_function/example/add_local_functor.cpp (original)
+++ trunk/libs/local_function/example/add_local_functor.cpp 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -17,6 +17,7 @@
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.
Modified: trunk/libs/local_function/example/const_block.hpp
==============================================================================
--- trunk/libs/local_function/example/const_block.hpp (original)
+++ trunk/libs/local_function/example/const_block.hpp 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -23,18 +23,22 @@
#define CONST_BLOCK_BIND_(r, unused, i, var) \
BOOST_PP_COMMA_IF(i) const bind& var
-#define CONST_BLOCK_(list) \
+//[const_block_macro
+#define CONST_BLOCK_(variables) \
void BOOST_LOCAL_FUNCTION( \
- BOOST_PP_IIF(BOOST_PP_LIST_IS_NIL(list), \
+ BOOST_PP_IIF(BOOST_PP_LIST_IS_NIL(variables, \
void BOOST_PP_TUPLE_EAT(3) \
, \
BOOST_PP_LIST_FOR_EACH_I \
- )(CONST_BLOCK_BIND_, ~, list) \
+ )(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 //
Modified: trunk/libs/local_function/example/expensive_copy_cxx11_lambda.cpp
==============================================================================
--- trunk/libs/local_function/example/expensive_copy_cxx11_lambda.cpp (original)
+++ trunk/libs/local_function/example/expensive_copy_cxx11_lambda.cpp 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -22,6 +22,7 @@
}
};
+
int main(void) {
n x(-1);
Modified: trunk/libs/local_function/example/gcc_lambda.hpp
==============================================================================
--- trunk/libs/local_function/example/gcc_lambda.hpp (original)
+++ trunk/libs/local_function/example/gcc_lambda.hpp 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -65,6 +65,7 @@
BOOST_PP_LIST_FIRST(results))
#ifdef BOOST_NO_LAMBDAS
+//[gcc_lambda_macro
# define GCC_LAMBDA_(binds, params, results) \
({ /* open statement expression (GCC extension only) */ \
BOOST_LOCAL_FUNCTION( \
@@ -78,6 +79,7 @@
) \
)) \
)
+//]
#else
# define GCC_LAMBDA_(binds, params, results) \
/* ignore const binding because not supported by C++11 lambdas */ \
@@ -95,10 +97,12 @@
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 //
Modified: trunk/libs/local_function/example/impl_tparam_tricks.cpp
==============================================================================
--- trunk/libs/local_function/example/impl_tparam_tricks.cpp (original)
+++ trunk/libs/local_function/example/impl_tparam_tricks.cpp 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -12,8 +12,8 @@
// Casting functor trick.
struct casting_func {
- explicit casting_func(void* obj, void (*call)(void*, const int&)):
- obj_(obj), call_(call) {}
+ 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:
@@ -37,14 +37,13 @@
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) {}
+ 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) {
+ inline static void call(void* obj, const int& num) {
local_add* self = static_cast<local_add*>(obj);
self->body(self->sum_, self->factor_, num);
}
Modified: trunk/libs/local_function/example/noncopyable_cxx11_lambda_error.cpp
==============================================================================
--- trunk/libs/local_function/example/noncopyable_cxx11_lambda_error.cpp (original)
+++ trunk/libs/local_function/example/noncopyable_cxx11_lambda_error.cpp 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -13,12 +13,13 @@
#include <boost/noncopyable.hpp>
#include <cassert>
-//[noncopyable_lambda_error
+//[noncopyable_cxx11_lambda_error
struct n: boost::noncopyable {
int i;
n(int _i): i(_i) {}
};
+
int main(void) {
n x(-1);
Modified: trunk/libs/local_function/example/noncopyable_local_function.cpp
==============================================================================
--- trunk/libs/local_function/example/noncopyable_local_function.cpp (original)
+++ trunk/libs/local_function/example/noncopyable_local_function.cpp 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -18,7 +18,7 @@
};
BOOST_TYPEOF_REGISTER_TYPE(n) // Register for `bind& x` below.
-int main() {
+int main(void) {
n x(-1);
void BOOST_LOCAL_FUNCTION(const bind& x) { // OK: No copy
Modified: trunk/libs/local_function/example/scope_exit.hpp
==============================================================================
--- trunk/libs/local_function/example/scope_exit.hpp (original)
+++ trunk/libs/local_function/example/scope_exit.hpp 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -25,10 +25,12 @@
// 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 //
@@ -36,8 +38,10 @@
# 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 \
Modified: trunk/libs/local_function/test/add.cpp
==============================================================================
--- trunk/libs/local_function/test/add.cpp (original)
+++ trunk/libs/local_function/test/add.cpp 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -26,7 +26,7 @@
int nums[] = {2, 3};
std::for_each(nums, nums + 2, add); // Pass it to an algorithm.
- BOOST_TEST(sum == 60); // Assert final summation value.
+ BOOST_TEST(sum == 60); // Assert final summation value.
return boost::report_errors();
}
//]
Modified: trunk/libs/local_function/test/add_inline.cpp
==============================================================================
--- trunk/libs/local_function/test/add_inline.cpp (original)
+++ trunk/libs/local_function/test/add_inline.cpp 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -21,7 +21,7 @@
void BOOST_LOCAL_FUNCTION(const bind factor, bind& sum, int num) {
sum += factor * num;
- } BOOST_LOCAL_FUNCTION_NAME(inline add) // Inlined.
+ } BOOST_LOCAL_FUNCTION_NAME(inline add) // Inlining.
std::vector<int> v(100);
std::fill(v.begin(), v.end(), 1);
Modified: trunk/libs/local_function/test/add_typed.cpp
==============================================================================
--- trunk/libs/local_function/test/add_typed.cpp (original)
+++ trunk/libs/local_function/test/add_typed.cpp 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -22,8 +22,8 @@
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 void) {
- this_->sum_ += factor * num;
+ 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);
Modified: trunk/libs/local_function/test/add_typed_seq.cpp
==============================================================================
--- trunk/libs/local_function/test/add_typed_seq.cpp (original)
+++ trunk/libs/local_function/test/add_typed_seq.cpp 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -15,8 +15,8 @@
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 void) ) {
- this_->sum_ += factor * num;
+ (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);
Modified: trunk/libs/local_function/test/goto.cpp
==============================================================================
--- trunk/libs/local_function/test/goto.cpp (original)
+++ trunk/libs/local_function/test/goto.cpp 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -14,8 +14,8 @@
//[goto
int error(int x, int y) {
- int BOOST_LOCAL_FUNCTION(int x) {
- if(x > 0) goto success; // OK: Can jump within local function.
+ int BOOST_LOCAL_FUNCTION(int z) {
+ if(z > 0) goto success; // OK: Can jump within local function.
return -1;
success:
return 0;
Modified: trunk/libs/local_function/test/goto_error.cpp
==============================================================================
--- trunk/libs/local_function/test/goto_error.cpp (original)
+++ trunk/libs/local_function/test/goto_error.cpp 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -14,8 +14,8 @@
//[goto_error
int error(int x, int y) {
- int BOOST_LOCAL_FUNCTION(int x) {
- if(x <= 0) goto failure; // Error: Cannot jump to enclosing scope.
+ 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;
Modified: trunk/libs/local_function/test/goto_error_seq.cpp
==============================================================================
--- trunk/libs/local_function/test/goto_error_seq.cpp (original)
+++ trunk/libs/local_function/test/goto_error_seq.cpp 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -8,8 +8,8 @@
#include <boost/local_function.hpp>
int error(int x, int y) {
- int BOOST_LOCAL_FUNCTION( (int x) ) {
- if(x <= 0) goto failure;
+ int BOOST_LOCAL_FUNCTION( (int z) ) {
+ if(z <= 0) goto failure;
else goto success;
success:
return 0;
Modified: trunk/libs/local_function/test/goto_seq.cpp
==============================================================================
--- trunk/libs/local_function/test/goto_seq.cpp (original)
+++ trunk/libs/local_function/test/goto_seq.cpp 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -8,8 +8,8 @@
#include <boost/local_function.hpp>
int error(int x, int y) {
- int BOOST_LOCAL_FUNCTION( (int x) ) {
- if(x > 0) goto success;
+ int BOOST_LOCAL_FUNCTION( (int z) ) {
+ if(z > 0) goto success;
return -1;
success:
return 0;
Modified: trunk/libs/local_function/test/operator_error.cpp
==============================================================================
--- trunk/libs/local_function/test/operator_error.cpp (original)
+++ trunk/libs/local_function/test/operator_error.cpp 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -15,7 +15,6 @@
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
#include <boost/detail/lightweight_test.hpp>
-//[operator_error
struct point {
int x;
int y;
@@ -23,16 +22,17 @@
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
Modified: trunk/libs/local_function/test/overload.cpp
==============================================================================
--- trunk/libs/local_function/test/overload.cpp (original)
+++ trunk/libs/local_function/test/overload.cpp 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -17,10 +17,12 @@
#include <string>
#include <cmath>
-//[overload
+//[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) {
@@ -43,6 +45,7 @@
BOOST_TEST(fabs(add(3.21) - 4.44) < 0.001); // Call `add_d` (no default).
BOOST_TEST(fabs(add(3.21, 40.0) - 44.44) < 0.001); // Call `add_d`.
BOOST_TEST(add(1, 2) == 3); // Call `add_i`.
+ //]
return boost::report_errors();
}
Modified: trunk/libs/local_function/test/same_line.cpp
==============================================================================
--- trunk/libs/local_function/test/same_line.cpp (original)
+++ trunk/libs/local_function/test/same_line.cpp 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -17,25 +17,44 @@
//[same_line
#define LOCAL_INC_DEC(offset) \
- int BOOST_LOCAL_FUNCTION_ID( \
- BOOST_PP_CAT(inc, __LINE__) /* unique ID */, 0 /* no TPL */, \
+ 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__) /* unique ID */, 0 /* no TPL */, \
+ 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) \
+ int BOOST_LOCAL_FUNCTION_TPL_ID(BOOST_PP_CAT(inc, __LINE__), \
+ const bind offset, const int x) { \
+ return x + offset; \
+ } BOOST_LOCAL_FUNCTION_NAME(inc) \
+ \
+ int BOOST_LOCAL_FUNCTION_TPL_ID(BOOST_PP_CAT(dec, __LINE__), \
+ const bind offset, const int x) { \
+ return x - offset; \
+ } BOOST_LOCAL_FUNCTION_NAME(dec)
+
+template<typename T>
+void f(int delta) {
+ LOCAL_INC_DEC_TPL(delta) // Multiple local functions on same line.
+ /** @todo back to BOOST_TEST(dec(inc(123)) == 123)) and doc that on vacpp compiler composition doesn't work */
+ BOOST_TEST(inc(123) == 123 + delta);
+ BOOST_TEST(dec(123) == 123 - delta);
+}
+
int main(void) {
int delta = 10;
+
LOCAL_INC_DEC(delta) // Multiple local functions on same line.
-
/** @todo back to BOOST_TEST(dec(inc(123)) == 123)) and doc that on vacpp compiler composition doesn't work */
- BOOST_TEST(inc(123) == 123 + 10);
- BOOST_TEST(dec(123) == 123 - 10);
+ BOOST_TEST(inc(123) == 123 + delta);
+ BOOST_TEST(dec(123) == 123 - delta);
+
+ f(delta);
return boost::report_errors();
}
//]
Modified: trunk/libs/local_function/test/same_line_seq.cpp
==============================================================================
--- trunk/libs/local_function/test/same_line_seq.cpp (original)
+++ trunk/libs/local_function/test/same_line_seq.cpp 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -23,12 +23,34 @@
return x - offset; \
} BOOST_LOCAL_FUNCTION_NAME(dec)
+#define LOCAL_INC_DEC_TPL(offset) \
+ int BOOST_LOCAL_FUNCTION_TPL_ID(BOOST_PP_CAT(inc, __LINE__), \
+ (const bind offset) (const int x) ) { \
+ return x + offset; \
+ } BOOST_LOCAL_FUNCTION_NAME(inc) \
+ \
+ int BOOST_LOCAL_FUNCTION_TPL_ID(BOOST_PP_CAT(dec, __LINE__), \
+ (const bind offset) (const int x) ) { \
+ return x - offset; \
+ } BOOST_LOCAL_FUNCTION_NAME(dec)
+
+template<typename T>
+void f(int delta) {
+ LOCAL_INC_DEC_TPL(delta) // Multiple local functions on same line.
+ /** @todo back to BOOST_TEST(dec(inc(123)) == 123)) and doc that on vacpp compiler composition doesn't work */
+ BOOST_TEST(inc(123) == 123 + delta);
+ BOOST_TEST(dec(123) == 123 - delta);
+}
+
int main(void) {
int delta = 10;
+
LOCAL_INC_DEC(delta) // Declare local functions on same line using `_ID`.
-
- BOOST_TEST(inc(123) == 123 + 10);
- BOOST_TEST(dec(123) == 123 - 10);
+ /** @todo back to BOOST_TEST(dec(inc(123)) == 123)) and doc that on vacpp compiler composition doesn't work */
+ BOOST_TEST(inc(123) == 123 + delta);
+ BOOST_TEST(dec(123) == 123 - delta);
+
+ f(delta);
return boost::report_errors();
}
Modified: trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT.html
==============================================================================
--- trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT.html (original)
+++ trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -33,7 +33,7 @@
</span>BOOST_SCOPE_EXIT(capture_list)</pre></div>
<div class="refsect1">
-<a name="id857198"></a><h2>Description</h2>
+<a name="id826178"></a><h2>Description</h2>
<p>The scope exit declaration schedules the execution of the scope exit body at the exit of the enclosing scope:</p>
<pre class="programlisting"> <span class="special">{</span> <span class="comment">// Some local scope.</span>
<span class="special">...</span>
Modified: trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_ALL.html
==============================================================================
--- trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_ALL.html (original)
+++ trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_ALL.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -33,7 +33,7 @@
</span>BOOST_SCOPE_EXIT_ALL(capture_list)</pre></div>
<div class="refsect1">
-<a name="id858688"></a><h2>Description</h2>
+<a name="id827672"></a><h2>Description</h2>
<p>This macro accepts a capture list starting with either <code class="computeroutput">&</code> or <code class="computeroutput">=</code> to capture all variables in scope by reference or value respectively (following the same syntax of C++11 lambdas). A part from that, this macro works like <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code> (see <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code> for more information):</p>
<pre class="programlisting"> <span class="special">{</span> <span class="comment">// Some local scope.</span>
<span class="special">...</span>
Modified: trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_ALL_ID.html
==============================================================================
--- trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_ALL_ID.html (original)
+++ trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_ALL_ID.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -33,7 +33,7 @@
</span>BOOST_SCOPE_EXIT_ALL_ID(id, capture_list)</pre></div>
<div class="refsect1">
-<a name="id859341"></a><h2>Description</h2>
+<a name="id828325"></a><h2>Description</h2>
<p>This macro is equivalent to <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_ALL.html" title="Macro BOOST_SCOPE_EXIT_ALL">BOOST_SCOPE_EXIT_ALL</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 <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_ALL.html" title="Macro BOOST_SCOPE_EXIT_ALL">BOOST_SCOPE_EXIT_ALL</a></code> for more information). As with <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_ALL.html" title="Macro BOOST_SCOPE_EXIT_ALL">BOOST_SCOPE_EXIT_ALL</a></code>, this macro is only available on C++11 compilers (specifically, on C++11 compilers that do not define the Boost.Config <code class="computeroutput">BOOST_NO_LAMBDAS</code> macro).</p>
<p><span class="bold"><strong>Parameters:</strong></span> </p>
<div class="informaltable"><table class="table">
Modified: trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_CONFIG_USE_LAMBDAS.html
==============================================================================
--- trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_CONFIG_USE_LAMBDAS.html (original)
+++ trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_CONFIG_USE_LAMBDAS.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -33,7 +33,7 @@
</span>BOOST_SCOPE_EXIT_CONFIG_USE_LAMBDAS</pre></div>
<div class="refsect1">
-<a name="id861468"></a><h2>Description</h2>
+<a name="id829911"></a><h2>Description</h2>
<p>If programmers define this configuration macro on a C++11 compiler for which the Boost.Config macro <code class="computeroutput">BOOST_NO_LAMBDAS</code> is not defined, the <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code> and <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_TPL.html" title="Macro BOOST_SCOPE_EXIT_TPL">BOOST_SCOPE_EXIT_TPL</a></code> macros will use C++11 lambda functions to declare scope exits. By default this macro is not defined.</p>
<p><span class="bold"><strong>Warning:</strong></span> When scope exits are implemented using lambda functions, the syntax of the capture list follows the exact same syntax of C++11 lambda captures which is in general different from the legacy capture syntax of this library. For example, C++11 lambdas require to capture data members by capturing the object <code class="computeroutput">this</code> while this library always allowed to capture data members directly. Therefore, when this configuration macro is defined, <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code> and <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_TPL.html" title="Macro BOOST_SCOPE_EXIT_TPL">BOOST_SCOPE_EXIT_TPL</a></code> are no longer backward compatible (and this is why this macro is not defined by default).</p>
<p>A semicolon <code class="computeroutput">;</code> can be used instead of <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_END.html" title="Macro BOOST_SCOPE_EXIT_END">BOOST_SCOPE_EXIT_END</a></code> when this configuration macro is defined (but it is recommended to always use <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_END.html" title="Macro BOOST_SCOPE_EXIT_END">BOOST_SCOPE_EXIT_END</a></code> so to maximize portability).</p>
Modified: trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_END.html
==============================================================================
--- trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_END.html (original)
+++ trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_END.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -33,7 +33,7 @@
</span>BOOST_SCOPE_EXIT_END</pre></div>
<div class="refsect1">
-<a name="id859502"></a><h2>Description</h2>
+<a name="id828486"></a><h2>Description</h2>
<p>This macro must follow the closing curly bracket <code class="computeroutput">}</code> that ends the body of either <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code> or <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_TPL.html" title="Macro BOOST_SCOPE_EXIT_TPL">BOOST_SCOPE_EXIT_TPL</a></code>:</p>
<pre class="programlisting"> <span class="special">{</span> <span class="comment">// Some local scope.</span>
<span class="special">...</span>
Modified: trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_END_ID.html
==============================================================================
--- trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_END_ID.html (original)
+++ trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_END_ID.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -33,7 +33,7 @@
</span>BOOST_SCOPE_EXIT_END_ID(id)</pre></div>
<div class="refsect1">
-<a name="id861336"></a><h2>Description</h2>
+<a name="id829779"></a><h2>Description</h2>
<p>This macro is equivalent to <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_END.html" title="Macro BOOST_SCOPE_EXIT_END">BOOST_SCOPE_EXIT_END</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 <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_END.html" title="Macro BOOST_SCOPE_EXIT_END">BOOST_SCOPE_EXIT_END</a></code> for more information).</p>
<p><span class="bold"><strong>Parameters:</strong></span> </p>
<div class="informaltable"><table class="table">
Modified: trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_ID.html
==============================================================================
--- trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_ID.html (original)
+++ trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_ID.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -33,7 +33,7 @@
</span>BOOST_SCOPE_EXIT_ID(id, capture_list)</pre></div>
<div class="refsect1">
-<a name="id858354"></a><h2>Description</h2>
+<a name="id827339"></a><h2>Description</h2>
<p>This macro is equivalent to <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</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 <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code> for more information).</p>
<p><span class="bold"><strong>Parameters:</strong></span> </p>
<div class="informaltable"><table class="table">
Modified: trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_TPL.html
==============================================================================
--- trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_TPL.html (original)
+++ trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_TPL.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -33,7 +33,7 @@
</span>BOOST_SCOPE_EXIT_TPL(capture_list)</pre></div>
<div class="refsect1">
-<a name="id857802"></a><h2>Description</h2>
+<a name="id826787"></a><h2>Description</h2>
<p>Various versions of the GCC compiler do not compile <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code> inside function templates. As a workaround, <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_TPL.html" title="Macro BOOST_SCOPE_EXIT_TPL">BOOST_SCOPE_EXIT_TPL</a></code> should be used instead of <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code> in these cases:</p>
<pre class="programlisting"> <span class="special">{</span> <span class="comment">// Some local scope.</span>
<span class="special">...</span>
Modified: trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_TPL_ID.html
==============================================================================
--- trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_TPL_ID.html (original)
+++ trunk/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_TPL_ID.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -33,7 +33,7 @@
</span>BOOST_SCOPE_EXIT_TPL_ID(id, capture_list)</pre></div>
<div class="refsect1">
-<a name="id858518"></a><h2>Description</h2>
+<a name="id827502"></a><h2>Description</h2>
<p>This macro is equivalent to <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_TPL.html" title="Macro BOOST_SCOPE_EXIT_TPL">BOOST_SCOPE_EXIT_TPL</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 <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_TPL.html" title="Macro BOOST_SCOPE_EXIT_TPL">BOOST_SCOPE_EXIT_TPL</a></code> for more information). As with <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_TPL.html" title="Macro BOOST_SCOPE_EXIT_TPL">BOOST_SCOPE_EXIT_TPL</a></code>, it is recommended to always use this macro when expanding scope exits multiple times on the same line within templates.</p>
<p><span class="bold"><strong>Parameters:</strong></span> </p>
<div class="informaltable"><table class="table">
Modified: trunk/libs/scope_exit/doc/html/index.html
==============================================================================
--- trunk/libs/scope_exit/doc/html/index.html (original)
+++ trunk/libs/scope_exit/doc/html/index.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -120,7 +120,7 @@
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"><p><small>Last revised: April 10, 2012 at 20:41:46 GMT</small></p></td>
+<td align="left"><p><small>Last revised: April 13, 2012 at 00:20:01 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
Modified: trunk/libs/scope_exit/doc/html/scope_exit/Getting_Started.html
==============================================================================
--- trunk/libs/scope_exit/doc/html/scope_exit/Getting_Started.html (original)
+++ trunk/libs/scope_exit/doc/html/scope_exit/Getting_Started.html 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -55,10 +55,11 @@
<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 (conceptually similar to <code class="computeroutput"><span class="identifier">assert</span></code>).
- A failure of the checked condition does not abort the execution of the program,
- it will instead make <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="scope_exit.Getting_Started.this_documentation.f0" href="#ftn.scope_exit.Getting_Started.this_documentation.f0" class="footnote">2</a>]</sup>
+ 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="scope_exit.Getting_Started.this_documentation.f0" href="#ftn.scope_exit.Getting_Started.this_documentation.f0" class="footnote">2</a>]</sup>
</p>
</div>
<div class="section scope_exit_Getting_Started_compilers_and_platforms">
Modified: trunk/libs/scope_exit/doc/scope_exit.qbk
==============================================================================
--- trunk/libs/scope_exit/doc/scope_exit.qbk (original)
+++ trunk/libs/scope_exit/doc/scope_exit.qbk 2012-04-12 20:26:10 EDT (Thu, 12 Apr 2012)
@@ -93,8 +93,8 @@
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 (conceptually similar to `assert`).
-A failure of the checked condition does not abort the execution of the program, it will instead make `boost::report_errors` return a non-zero program exit code.
+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.
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk