|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r77906 - in trunk: boost boost/local_function/aux_/macro libs/local_function/doc libs/local_function/doc/html libs/local_function/doc/html/boost_localfunction libs/local_function/test
From: lorcaminiti_at_[hidden]
Date: 2012-04-11 01:47:40
Author: lcaminiti
Date: 2012-04-11 01:47:37 EDT (Wed, 11 Apr 2012)
New Revision: 77906
URL: http://svn.boost.org/trac/boost/changeset/77906
Log:
Upd docs and added ability to pass function type and default count to NAME so to not use Boost.Typeof at all.
Text files modified:
trunk/boost/local_function.hpp | 22 +-
trunk/boost/local_function/aux_/macro/name.hpp | 239 ++++++++++++++++++---------------------
trunk/libs/local_function/doc/advanced_topics.qbk | 2
trunk/libs/local_function/doc/getting_started.qbk | 14 -
trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION.html | 2
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 | 8
trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_ID.html | 2
trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_NAME.html | 8
trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TPL.html | 2
trunk/libs/local_function/doc/html/BOOST_LOCAL_FUNCTION_TYPEOF.html | 8
trunk/libs/local_function/doc/html/boost_localfunction/Advanced_Topics.html | 176 ++++++++++++-----------------
trunk/libs/local_function/doc/html/boost_localfunction/Alternatives.html | 213 +++++++++++++----------------------
trunk/libs/local_function/doc/html/boost_localfunction/Examples.html | 100 +++++++---------
trunk/libs/local_function/doc/html/boost_localfunction/Getting_Started.html | 29 +---
trunk/libs/local_function/doc/html/boost_localfunction/Implementation.html | 36 ++---
trunk/libs/local_function/doc/html/boost_localfunction/No_Variadic_Macros.html | 20 +-
trunk/libs/local_function/doc/html/boost_localfunction/Release_Notes.html | 6
trunk/libs/local_function/doc/html/boost_localfunction/Tutorial.html | 31 ++--
trunk/libs/local_function/doc/html/index.html | 39 +++---
trunk/libs/local_function/doc/html/reference.html | 10 +
trunk/libs/local_function/doc/introduction.qbk | 16 +-
trunk/libs/local_function/doc/local_function.qbk | 16 +-
trunk/libs/local_function/test/add_typed.cpp | 17 +-
trunk/libs/local_function/test/add_typed_seq.cpp | 13 -
25 files changed, 446 insertions(+), 585 deletions(-)
Modified: trunk/boost/local_function.hpp
==============================================================================
--- trunk/boost/local_function.hpp (original)
+++ trunk/boost/local_function.hpp 2012-04-11 01:47:37 EDT (Wed, 11 Apr 2012)
@@ -14,6 +14,7 @@
#include <boost/local_function/aux_/macro/name.hpp>
#include <boost/local_function/aux_/macro/typeof.hpp>
#include <boost/local_function/aux_/preprocessor/traits/decl.hpp>
+#include <boost/local_function/aux_/preprocessor/traits/name.hpp>
#include <boost/local_function/detail/preprocessor/line_counter.hpp>
#include <boost/local_function/detail/preprocessor/void_list.hpp>
#include <boost/config.hpp>
@@ -45,13 +46,12 @@
BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER, 1, __VA_ARGS__)
#endif // VARIADIC
-#define BOOST_LOCAL_FUNCTION_NAME(qualified_function_name) \
+#define BOOST_LOCAL_FUNCTION_NAME(name) \
BOOST_LOCAL_FUNCTION_AUX_NAME(0, /* not within template */ \
- qualified_function_name)
-
-#define BOOST_LOCAL_FUNCTION_NAME_TPL(qualified_function_name) \
+ BOOST_LOCAL_FUNCTION_AUX_PP_NAME_TRAITS(name))
+#define BOOST_LOCAL_FUNCTION_NAME_TPL(name) \
BOOST_LOCAL_FUNCTION_AUX_NAME(1, /* within template */ \
- qualified_function_name)
+ BOOST_LOCAL_FUNCTION_AUX_PP_NAME_TRAITS(name))
#define BOOST_LOCAL_FUNCTION_TYPEOF(bound_variable_name) \
BOOST_LOCAL_FUNCTION_AUX_TYPEOF_TYPE(bound_variable_name)
@@ -246,17 +246,17 @@
...
result_type BOOST_LOCAL_FUNCTION(declarations) {
... // Body code.
- } BOOST_LOCAL_FUNCTION_NAME(qualified_function_name)
+ } BOOST_LOCAL_FUNCTION_NAME(name)
...
}
@endcode
@Params
-_at_Param{qualified_function_name,
+@Param{name,
The name of the local function optionally qualified as follow:
@code
-qualified_function_name:
- [inline] [recursive] name
+name:
+ [(function_type)[(defaults)]] [inline] [recursive] function_name
@endcode
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;
@@ -300,12 +300,12 @@
@RefSectId{Advanced_Topics, Advanced Topics} section,
@RefMacro{BOOST_LOCAL_FUNCTION}.
*/
-#define BOOST_LOCAL_FUNCTION_NAME(qualified_function_name)
+#define BOOST_LOCAL_FUNCTION_NAME(name)
/**
In type-dependant context.
*/
-#define BOOST_LOCAL_FUNCTION_NAME_TPL(qualified_function_name)
+#define BOOST_LOCAL_FUNCTION_NAME_TPL(name)
/**
@brief This macro expands to the type of the specified bound variable.
Modified: trunk/boost/local_function/aux_/macro/name.hpp
==============================================================================
--- trunk/boost/local_function/aux_/macro/name.hpp (original)
+++ trunk/boost/local_function/aux_/macro/name.hpp 2012-04-11 01:47:37 EDT (Wed, 11 Apr 2012)
@@ -8,11 +8,11 @@
#ifndef BOOST_LOCAL_FUNCTION_AUX_NAME_HPP_
#define BOOST_LOCAL_FUNCTION_AUX_NAME_HPP_
+
#include <boost/local_function/config.hpp>
#include <boost/local_function/aux_/macro/decl.hpp>
#include <boost/local_function/aux_/macro/code_/functor.hpp>
-#include <boost/local_function/detail/preprocessor/keyword/recursive.hpp>
-#include <boost/local_function/detail/preprocessor/keyword/inline.hpp>
+#include <boost/local_function/aux_/preprocessor/traits/name.hpp>
#include <boost/local_function/aux_/function.hpp>
#include <boost/local_function/aux_/symbol.hpp>
#include <boost/typeof/typeof.hpp>
@@ -26,16 +26,44 @@
#define BOOST_LOCAL_FUNCTION_AUX_NAME_INIT_RECURSION_FUNC_ \
BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (init_recursion) )
-#define BOOST_LOCAL_FUNCTION_AUX_NAME_RECURSIVE_FUNC_( \
- is_recursive, local_function_name) \
- BOOST_PP_IIF(is_recursive, \
- local_function_name \
+#define BOOST_LOCAL_FUNCTION_AUX_NAME_RECURSIVE_FUNC_(name_traits) \
+ BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_AUX_PP_NAME_TRAITS_IS_RECURSIVE( \
+ name_traits), \
+ BOOST_LOCAL_FUNCTION_AUX_PP_NAME_TRAITS_FUNCTION_NAME \
, \
BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (nonrecursive_local_function_name) ) \
- )
+ BOOST_PP_TUPLE_EAT(1) \
+ )(name_traits)
+
+#define BOOST_LOCAL_FUNCTION_AUX_NAME_FUNCTOR_TYPEOF_( \
+ typename01, name_traits, local_functor_name) \
+ BOOST_PP_IIF(typename01, \
+ BOOST_TYPEOF_TPL \
+ , \
+ BOOST_TYPEOF \
+ )(local_functor_name.BOOST_LOCAL_FUNCTION_AUX_NAME_RECURSIVE_FUNC_( \
+ name_traits))
+
+#define BOOST_LOCAL_FUNCTION_AUX_NAME_FUNCTOR_TYPED_( \
+ typename01, name_traits, local_functor_name) \
+ BOOST_PP_EXPR_IIF(typename01, typename) \
+ BOOST_IDENTITY_TYPE((::boost::local_function::aux::function< \
+ BOOST_LOCAL_FUNCTION_AUX_PP_NAME_TRAITS_FUNCTION_TYPE( \
+ name_traits) \
+ , BOOST_LOCAL_FUNCTION_AUX_PP_NAME_TRAITS_DEFAULTS(name_traits) \
+ >))
+
+#define BOOST_LOCAL_FUNCTION_AUX_NAME_FUNCTOR_TYPE_( \
+ typename01, name_traits, local_functor_name) \
+ BOOST_PP_IIF(BOOST_PP_IS_EMPTY( \
+ BOOST_LOCAL_FUNCTION_AUX_PP_NAME_TRAITS_FUNCTION_TYPE( \
+ name_traits)), \
+ BOOST_LOCAL_FUNCTION_AUX_NAME_FUNCTOR_TYPEOF_ \
+ , \
+ BOOST_LOCAL_FUNCTION_AUX_NAME_FUNCTOR_TYPED_ \
+ )(typename01, name_traits, local_functor_name)
-#define BOOST_LOCAL_FUNCTION_AUX_NAME_END_LOCAL_FUNCTOR_(typename01, \
- local_function_name, is_recursive, \
+#define BOOST_LOCAL_FUNCTION_AUX_NAME_LOCAL_FUNCTOR_(typename01, name_traits, \
local_functor_name, nonlocal_functor_name) \
/* `PARAMS() { ... }` expandsion here -- still within functor class */ \
/* class functor ## __LINE__ { ... */ \
@@ -50,34 +78,30 @@
/* because this cannot be a mem ref because its name is not known */ \
/* by the constructor so it cannot be set by the mem init list */ \
BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_TYPE \
- BOOST_LOCAL_FUNCTION_AUX_NAME_RECURSIVE_FUNC_(is_recursive, \
- local_function_name); \
- BOOST_PP_EXPR_IIF(is_recursive, \
+ BOOST_LOCAL_FUNCTION_AUX_NAME_RECURSIVE_FUNC_(name_traits); \
+ BOOST_PP_EXPR_IIF(BOOST_LOCAL_FUNCTION_AUX_PP_NAME_TRAITS_IS_RECURSIVE(\
+ name_traits), \
/* run-time: the `init_recursion()` function cannot be called */ \
/* by the constructor to allow for compiler optimization */ \
/* (inlining) so it must be public */ \
inline void BOOST_LOCAL_FUNCTION_AUX_NAME_INIT_RECURSION_FUNC_( \
BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_TYPE& functor) { \
- local_function_name = functor; \
+ BOOST_LOCAL_FUNCTION_AUX_PP_NAME_TRAITS_FUNCTION_NAME( \
+ name_traits) = functor; \
} \
) \
/* local functor can be passed as tparam only on C++11 (faster) */ \
} local_functor_name(BOOST_LOCAL_FUNCTION_AUX_DECL_ARGS_VAR.value); \
/* non-local functor can always be passed as tparam (but slower) */ \
- BOOST_PP_IIF(typename01, \
- BOOST_TYPEOF_TPL \
- , \
- BOOST_TYPEOF \
- )(local_functor_name.BOOST_LOCAL_FUNCTION_AUX_NAME_RECURSIVE_FUNC_( \
- is_recursive, local_function_name)) \
- nonlocal_functor_name /* functor variable */ \
- ; \
+ BOOST_LOCAL_FUNCTION_AUX_NAME_FUNCTOR_TYPE_(typename01, name_traits, \
+ local_functor_name) nonlocal_functor_name; /* functor variable */ \
/* the order of the following 2 function calls cannot be changed */ \
/* because init_recursion uses the local_functor so the local_functor */ \
/* must be init first */ \
local_functor_name.BOOST_LOCAL_FUNCTION_AUX_FUNCTION_INIT_CALL_FUNC( \
&local_functor_name, nonlocal_functor_name); \
- BOOST_PP_EXPR_IIF(is_recursive, \
+ BOOST_PP_EXPR_IIF(BOOST_LOCAL_FUNCTION_AUX_PP_NAME_TRAITS_IS_RECURSIVE( \
+ name_traits), \
/* init recursion causes MSVC to not optimize local function not */ \
/* even when local functor is used as template parameter so no */ \
/* recursion unless all inlining optimizations are specified off */ \
@@ -88,116 +112,71 @@
#define BOOST_LOCAL_FUNCTION_AUX_NAME_FUNCTOR_(local_function_name) \
BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (local_function_name) )
-// This can always be passed as a template parameters (on all compilers).
-// However, it is slower because it cannot be inlined.
-// Passed at tparam: Yes (on all C++). Inlineable: No. Recursive: No.
-#define BOOST_LOCAL_FUNCTION_AUX_NAME_(typename01, local_function_name) \
- BOOST_LOCAL_FUNCTION_AUX_NAME_END_LOCAL_FUNCTOR_(typename01, \
- local_function_name, \
- /* local function is not recursive (because recursion and its */ \
- /* initialization cannot be inlined even on C++11, */ \
- /* so this allows optimization at least on C++11) */ \
- 0 /* not recursive */ , \
- /* local functor */ \
- BOOST_LOCAL_FUNCTION_AUX_NAME_FUNCTOR_(local_function_name), \
- /* local function declared as non-local functor -- but it can */ \
- /* be inlined only by C++11 and it cannot be recursive */ \
- local_function_name)
-
-// This is faster on some compilers but not all (e.g., it is faster on GCC
-// because its optimization inlines it but not on MSVC). However, it cannot be
-// passed as a template parameter on non C++11 compilers.
-// Passed at tparam: Only on C++11. Inlineable: Yes. Recursive: No.
-#define BOOST_LOCAL_FUNCTION_AUX_NAME_INLINE_(typename01, local_function_name) \
- BOOST_LOCAL_FUNCTION_AUX_NAME_END_LOCAL_FUNCTOR_(typename01, \
- local_function_name, \
- /* inlined local function is never recursive (because recursion */ \
- /* and its initialization cannot be inlined)*/ \
- 0 /* not recursive */ , \
- /* inlined local function declared as local functor (maybe */ \
- /* inlined even by non C++11 -- but it can be passed as */ \
- /* template parameter only on C++11 */ \
- local_function_name, \
- /* non-local functor */ \
- BOOST_LOCAL_FUNCTION_AUX_NAME_FUNCTOR_(local_function_name))
-
-// This is slower on all compilers (C++11 and non) because recursion and its
-// initialization can never be inlined.
-// Passed at tparam: Yes. Inlineable: No. Recursive: Yes.
-#define BOOST_LOCAL_FUNCTION_AUX_NAME_RECURSIVE_( \
- typename01, local_function_name) \
- BOOST_LOCAL_FUNCTION_AUX_NAME_END_LOCAL_FUNCTOR_(typename01, \
- local_function_name, \
- /* recursive local function -- but it cannot be inlined */ \
- 1 /* recursive */ , \
- /* local functor */ \
- BOOST_LOCAL_FUNCTION_AUX_NAME_FUNCTOR_(local_function_name), \
- /* local function declared as non-local functor -- but it can */ \
- /* be inlined only by C++11 */ \
- local_function_name)
-
-// Inlined local functions are specified by `..._NAME(inline name)`.
-// They have more chances to be inlined for faster run-times by some compilers
-// (for example by GCC but not by MSVC). C++11 compilers can always inline
-// local functions even if they are not explicitly specified inline.
-#define BOOST_LOCAL_FUNCTION_AUX_NAME_PARSE_INLINE_( \
- typename01, qualified_name) \
- BOOST_PP_IIF(BOOST_PP_BITOR( \
- BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS, \
- BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_IS_INLINE_FRONT( \
- qualified_name)), \
- /* on C++11 always use inlining because compilers might optimize */ \
- /* it to be faster and it can also be passed as tparam */ \
- BOOST_LOCAL_FUNCTION_AUX_NAME_INLINE_ \
- , \
- /* on non C++11 don't use liniling unless explicitly specified by */ \
- /* programmers `inline name` the inlined local function cannot be */ \
- /* passed as tparam */ \
- BOOST_LOCAL_FUNCTION_AUX_NAME_ \
- )(typename01, BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_INLINE_REMOVE_FRONT( \
- qualified_name))
-
-// Expand to 1 iff `recursive name` or `recursive inline name` or
-// `inline recursive name`.
-#define BOOST_LOCAL_FUNCTION_AUX_NAME_IS_RECURSIVE_(qualified_name) \
- BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_IS_RECURSIVE_FRONT( \
- BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_INLINE_REMOVE_FRONT( \
- qualified_name \
- ))
-
-// Revmoes `recursive`, `inline recursive`, and `recursive inline` from front.
-#define BOOST_LOCAL_FUNCTION_AUX_NAME_REMOVE_RECURSIVE_AND_INLINE_( \
- qualified_name) \
- BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_RECURSIVE_REMOVE_FRONT( \
- BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_INLINE_REMOVE_FRONT( \
- BOOST_LOCAL_FUNCTION_DETAIL_PP_KEYWORD_RECURSIVE_REMOVE_FRONT( \
- qualified_name \
- )))
-
-#define BOOST_LOCAL_FUNCTION_AUX_NAME_RECURSIVE_REMOVE_(qualified_name) \
- BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_AUX_NAME_IS_RECURSIVE_(qualified_name), \
- BOOST_LOCAL_FUNCTION_AUX_NAME_REMOVE_RECURSIVE_AND_INLINE_ \
- , \
- qualified_name /* might be `name` or `inline name` */ \
- BOOST_PP_TUPLE_EAT(1) \
- )(qualified_name)
-
-// Recursive local function are specified by `..._NAME(recursive name)`.
-// They can never be inlined for faster run-time (not even by C++11 compilers).
-#define BOOST_LOCAL_FUNCTION_AUX_NAME_PARSE_RECURSIVE_( \
- typename01, qualified_name) \
- BOOST_PP_IIF(BOOST_LOCAL_FUNCTION_AUX_NAME_IS_RECURSIVE_(qualified_name), \
- /* recursion can never be inlined (not even on C++11) */ \
- BOOST_LOCAL_FUNCTION_AUX_NAME_RECURSIVE_ \
- , \
- BOOST_LOCAL_FUNCTION_AUX_NAME_PARSE_INLINE_ \
- )(typename01, \
- BOOST_LOCAL_FUNCTION_AUX_NAME_RECURSIVE_REMOVE_(qualified_name))
-
// PUBLIC //
-#define BOOST_LOCAL_FUNCTION_AUX_NAME(typename01, qualified_name) \
- BOOST_LOCAL_FUNCTION_AUX_NAME_PARSE_RECURSIVE_(typename01, qualified_name)
+// If !INLINE(name_traits) && !RECURSIVE(name_traits):
+// This can always be passed as a template parameters (on all compilers).
+// However, it is slower because it cannot be inlined.
+// If !INLINE(name_traits) && RECURSIVE(name_traits):
+// This is slower on all compilers (C++11 and non) because recursion and
+// its initialization can never be inlined.
+// If INLINE(name_traits) && !RECURSIVE(name_traits):
+// This is faster on some compilers but not all (e.g., it is faster on GCC
+// because its optimization inlines it but not on MSVC). However, it
+// cannot be passed as a template parameter on non C++11 compilers.
+// If INLINE(name_traits) && RECURSIVE(name_traits):
+// Same as RECURSIVE && !INLINE.
+#define BOOST_LOCAL_FUNCTION_AUX_NAME(typename01, name_traits) \
+ BOOST_PP_EXPAND( \
+ BOOST_LOCAL_FUNCTION_AUX_NAME_LOCAL_FUNCTOR_ \
+ BOOST_PP_IIF( /* !RECURSIVE && (C++11 || INLINE) => FASTER */ \
+ BOOST_PP_BITAND( \
+ BOOST_PP_COMPL( \
+ BOOST_LOCAL_FUNCTION_AUX_PP_NAME_TRAITS_IS_RECURSIVE( \
+ name_traits)) \
+ , BOOST_PP_BITOR( \
+ /* on C++11 always use inlining because compilers */ \
+ /* might optimize it to be faster and it can also */ \
+ /* be passed as template parameter */ \
+ BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS \
+ , BOOST_LOCAL_FUNCTION_AUX_PP_NAME_TRAITS_IS_INLINE( \
+ name_traits) \
+ ) \
+ ), \
+ /* inlined local function declared as local functor: it maybe */ \
+ /* always be inlined (faster) but it can be passed as template */ \
+ /* parameter only by C++11 -- never recursive */ \
+ ( \
+ typename01 \
+ , \
+ name_traits \
+ , \
+ BOOST_LOCAL_FUNCTION_AUX_PP_NAME_TRAITS_FUNCTION_NAME( \
+ name_traits) \
+ , \
+ BOOST_LOCAL_FUNCTION_AUX_NAME_FUNCTOR_( \
+ BOOST_LOCAL_FUNCTION_AUX_PP_NAME_TRAITS_FUNCTION_NAME( \
+ name_traits)) \
+ ) \
+ , /* RECURSIVE || (!C++11 && !INLINE) => SLOWER */ \
+ /* local function declared as non-local functor: it can always */ \
+ /* be passed as template parameter but slower even on C++11 if */ \
+ /* declared recursive -- it can be inlined (faster) only by */ \
+ /* C++11 and if not recursive */ \
+ ( \
+ typename01 \
+ , \
+ name_traits \
+ , \
+ BOOST_LOCAL_FUNCTION_AUX_NAME_FUNCTOR_( \
+ BOOST_LOCAL_FUNCTION_AUX_PP_NAME_TRAITS_FUNCTION_NAME( \
+ name_traits)) \
+ , \
+ BOOST_LOCAL_FUNCTION_AUX_PP_NAME_TRAITS_FUNCTION_NAME( \
+ name_traits) \
+ ) \
+ ) \
+ )
#endif // #include guard
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-11 01:47:37 EDT (Wed, 11 Apr 2012)
@@ -147,7 +147,7 @@
[endsect]
-[section Assigning and Returning]
+[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.
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-11 01:47:37 EDT (Wed, 11 Apr 2012)
@@ -18,10 +18,11 @@
Some footnotes are marked by the word "*Rationale*".
They explain reasons behind decisions made during the design and implementation of this library.
-In some of the examples presented in this documentation, the __Boost_Test__ macro `BOOST_CHECK` is used equivalently to `assert` and the __Boost_Test__ macro `BOOST_AUTO_TEST_CASE` is used equivalently to `main`.
+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.
[footnote
*Rationale.*
-Using __Boost_Test__ allows to add the documentation examples to the library regression tests so to make sure that the listed examples always compile and run correctly.
+Using Boost.Detail/LightweightTest allows to add the examples to the library regression tests so to make sure that they always compile and run correctly.
]
[endsect]
@@ -29,11 +30,11 @@
[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 __CPP03__ standard.
+As a consequence, this library is fairly demanding on compilers' compliance with the __CXX03__ standard.
The authors originally developed and tested the library on:
# GNU Compiler Collection (GCC) C++ 4.5.1 on Ubuntu Linux 10.
-# GCC 4.3.4 and 4.5.3 (with and without __CPP11__ features enabled `-std=c++0x`) on Cygwin.
+# GCC 4.3.4 and 4.5.3 (with and without __CXX11__ features enabled `-std=c++0x`) on Cygwin.
# Miscrosoft Visual C++ (MSVC) 8.0 on Windows XP and Windows 7.
See the library [@http://www.boost.org/development/tests/release/developer/local_function.html regressions test results] for detailed information on supported compilers and platforms.
@@ -62,13 +63,8 @@
* Any symbol prefixed by `boost_local_function_aux_...` or `boost_local_function_detail_...` (regardless of its namespace).
* Any symbol prefixed by `BOOST_LOCAL_FUNCTION_AUX_...` or `BOOST_LOCAL_FUNCTION_DETAIL_...` (regardless of its namespace).
-[endsect]
-
-[section Configuration]
-
Some of the library behaviour can be changed at compile-time by defining special /configuration macros/.
If a configuration macro is left undefined, the library will use an appropriate default value for it.
-
All configuration macros are defined in the header file [headerref boost/local_function/config.hpp].
It is strongly recommended not to change the library configuration macro definitions unless strictly necessary.
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-11 01:47:37 EDT (Wed, 11 Apr 2012)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_FUNCTION(declarations)</pre></div>
<div class="refsect1">
-<a name="id869098"></a><h2>Description</h2>
+<a name="id903202"></a><h2>Description</h2>
<p>This macro must be used within a declarative context, it must follow the local function result type, it must be followed by the local function body code, and then by the <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code> macro (see the <a class="link" href="boost_localfunction/Tutorial.html" title="Tutorial">Tutorial</a> and <a class="link" href="boost_localfunction/Advanced_Topics.html" title="Advanced Topics"> Advanced Topics</a> sections): </p>
<pre class="programlisting"><span class="special">{</span> <span class="comment">// Some declarative context.</span>
<span class="special">...</span>
Modified: 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-11 01:47:37 EDT (Wed, 11 Apr 2012)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX</pre></div>
<div class="refsect1">
-<a name="id870681"></a><h2>Description</h2>
+<a name="id904846"></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-11 01:47:37 EDT (Wed, 11 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.config_hpp" title="Header <boost/local_function/config.hpp>">
<link rel="prev" href="BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX">
-<link rel="next" href="boost_localfunction/Alternatives.html" title="Annex: Alternatives">
+<link rel="next" href="BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
@@ -20,7 +20,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
-<a accesskey="p" href="BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function.config_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost_localfunction/Alternatives.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function.config_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX"></a><div class="titlepage"></div>
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX</pre></div>
<div class="refsect1">
-<a name="id870755"></a><h2>Description</h2>
+<a name="id904921"></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>
@@ -50,7 +50,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
-<a accesskey="p" href="BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function.config_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost_localfunction/Alternatives.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function.config_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
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-11 01:47:37 EDT (Wed, 11 Apr 2012)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_FUNCTION_ID(id, within_template, declarations)</pre></div>
<div class="refsect1">
-<a name="id869962"></a><h2>Description</h2>
+<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>
<p><span class="bold"><strong>Parameters:</strong></span> </p>
<div class="informaltable"><table class="table">
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-11 01:47:37 EDT (Wed, 11 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_ID.html" title="Macro BOOST_LOCAL_FUNCTION_ID">
-<link rel="next" href="BOOST_LOCAL_FUNCTION_TYPEOF.html" title="Macro BOOST_LOCAL_FUNCTION_TYPEOF">
+<link rel="next" href="BOOST_LOCAL_FUNCTION_NAME_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_NAME_TPL">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
@@ -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_TYPEOF.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+<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>
</div>
<div class="refentry">
<a name="BOOST_LOCAL_FUNCTION_NAME"></a><div class="titlepage"></div>
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_FUNCTION_NAME(qualified_function_name)</pre></div>
<div class="refsect1">
-<a name="id870159"></a><h2>Description</h2>
+<a name="id904287"></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>
@@ -75,7 +75,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_TYPEOF.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+<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>
</div>
</body>
</html>
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-11 01:47:37 EDT (Wed, 11 Apr 2012)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_FUNCTION_TPL(declarations)</pre></div>
<div class="refsect1">
-<a name="id869783"></a><h2>Description</h2>
+<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>
<span class="special">...</span>
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-11 01:47:37 EDT (Wed, 11 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_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">
+<link rel="prev" href="BOOST_LOCAL_FUNCTION_NAME_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_NAME_TPL">
<link rel="next" href="BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
@@ -20,7 +20,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
-<a accesskey="p" href="BOOST_LOCAL_FUNCTION_NAME.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_NAME_TPL.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="BOOST_LOCAL_FUNCTION_TYPEOF"></a><div class="titlepage"></div>
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_FUNCTION_TYPEOF(bound_variable_name)</pre></div>
<div class="refsect1">
-<a name="id870468"></a><h2>Description</h2>
+<a name="id904629"></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">
@@ -72,7 +72,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
-<a accesskey="p" href="BOOST_LOCAL_FUNCTION_NAME.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_NAME_TPL.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local_function_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
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-11 01:47:37 EDT (Wed, 11 Apr 2012)
@@ -31,8 +31,8 @@
Parameters</a></span></dt>
<dt><span class="section"><a href="Advanced_Topics.html#boost_localfunction.Advanced_Topics.commas_and_symbols_in_macros">Commas
and Symbols in Macros</a></span></dt>
-<dt><span class="section"><a href="Advanced_Topics.html#boost_localfunction.Advanced_Topics.assigning_and_returning">Assigning
- and Returning</a></span></dt>
+<dt><span class="section"><a href="Advanced_Topics.html#boost_localfunction.Advanced_Topics.assignments_and_returns">Assignments
+ and Returns</a></span></dt>
<dt><span class="section">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>
@@ -77,11 +77,11 @@
</p>
<p>
</p>
-<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">y</span><span class="special">,</span> <span class="keyword">default</span> <span class="number">2</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Default.</span>
+<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">y</span><span class="special">,</span> <span class="keyword">default</span> <span class="number">2</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Default parameter.</span>
<span class="keyword">return</span> <span class="identifier">x</span> <span class="special">+</span> <span class="identifier">y</span><span class="special">;</span>
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">add</span><span class="special">)</span>
-<span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">add</span><span class="special">(</span><span class="number">1</span><span class="special">)</span> <span class="special">==</span> <span class="number">3</span><span class="special">);</span>
+<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">add</span><span class="special">(</span><span class="number">1</span><span class="special">)</span> <span class="special">==</span> <span class="number">3</span><span class="special">);</span>
</pre>
<p>
</p>
@@ -103,7 +103,7 @@
<span class="keyword">return</span> <span class="identifier">x</span> <span class="special">+</span> <span class="identifier">y</span><span class="special">;</span>
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">add</span><span class="special">)</span>
-<span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">add</span><span class="special">(</span><span class="number">1</span><span class="special">)</span> <span class="special">==</span> <span class="number">3</span><span class="special">);</span>
+<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">add</span><span class="special">(</span><span class="number">1</span><span class="special">)</span> <span class="special">==</span> <span class="number">3</span><span class="special">);</span>
</pre>
<p>
</p>
@@ -287,10 +287,10 @@
<p>
</p>
</div>
-<div class="section boost_localfunction_Advanced_Topics_assigning_and_returning">
+<div class="section boost_localfunction_Advanced_Topics_assignments_and_returns">
<div class="titlepage"><div><div><h3 class="title">
-<a name="boost_localfunction.Advanced_Topics.assigning_and_returning"></a><a class="link" href="Advanced_Topics.html#boost_localfunction.Advanced_Topics.assigning_and_returning" title="Assigning and Returning">Assigning
- and Returning</a>
+<a name="boost_localfunction.Advanced_Topics.assignments_and_returns"></a><a class="link" href="Advanced_Topics.html#boost_localfunction.Advanced_Topics.assignments_and_returns" title="Assignments and Returns">Assignments
+ and Returns</a>
</h3></div></div></div>
<p>
Local functions are function objects so it is possible to assign them to
@@ -304,8 +304,8 @@
</p>
<p>
</p>
-<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">call1</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special"><</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">f</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">f</span><span class="special">(</span><span class="number">1</span><span class="special">)</span> <span class="special">==</span> <span class="number">5</span><span class="special">);</span> <span class="special">}</span>
-<span class="keyword">void</span> <span class="identifier">call0</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special"><</span><span class="keyword">int</span> <span class="special">(</span><span class="keyword">void</span><span class="special">)></span> <span class="identifier">f</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">f</span><span class="special">()</span> <span class="special">==</span> <span class="number">5</span><span class="special">);</span> <span class="special">}</span>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">call1</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special"><</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">f</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">f</span><span class="special">(</span><span class="number">1</span><span class="special">)</span> <span class="special">==</span> <span class="number">5</span><span class="special">);</span> <span class="special">}</span>
+<span class="keyword">void</span> <span class="identifier">call0</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special"><</span><span class="keyword">int</span> <span class="special">(</span><span class="keyword">void</span><span class="special">)></span> <span class="identifier">f</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">f</span><span class="special">()</span> <span class="special">==</span> <span class="number">5</span><span class="special">);</span> <span class="special">}</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special"><</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="identifier">linear</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">int</span><span class="special">&</span> <span class="identifier">slope</span><span class="special">)</span> <span class="special">{</span>
<span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">&</span> <span class="identifier">slope</span><span class="special">,</span>
@@ -314,7 +314,7 @@
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">lin</span><span class="special">)</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special"><</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="identifier">f</span> <span class="special">=</span> <span class="identifier">lin</span><span class="special">;</span> <span class="comment">// Assign to local variable.</span>
- <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">f</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="number">2</span><span class="special">)</span> <span class="special">==</span> <span class="number">5</span><span class="special">);</span>
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">f</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="number">2</span><span class="special">)</span> <span class="special">==</span> <span class="number">5</span><span class="special">);</span>
<span class="identifier">call1</span><span class="special">(</span><span class="identifier">lin</span><span class="special">);</span> <span class="comment">// Pass to other functions.</span>
<span class="identifier">call0</span><span class="special">(</span><span class="identifier">lin</span><span class="special">);</span>
@@ -324,7 +324,7 @@
<span class="keyword">void</span> <span class="identifier">call</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special"><</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="identifier">f</span> <span class="special">=</span> <span class="identifier">linear</span><span class="special">(</span><span class="number">2</span><span class="special">);</span>
- <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">f</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="number">2</span><span class="special">)</span> <span class="special">==</span> <span class="number">5</span><span class="special">);</span>
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">f</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="number">2</span><span class="special">)</span> <span class="special">==</span> <span class="number">5</span><span class="special">);</span>
<span class="special">}</span>
</pre>
<p>
@@ -338,15 +338,14 @@
<th align="left">Warning</th>
</tr>
<tr><td align="left" valign="top"><p>
- As with <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> 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 __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.
</p></td></tr>
</table></div>
<p>
@@ -363,7 +362,7 @@
<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">w</span><span class="special">;</span>
<span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><=</span> <span class="number">2</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">i</span> <span class="special">*</span> <span class="number">10</span><span class="special">);</span>
-<span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">v</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="special">==</span> <span class="number">10</span><span class="special">);</span> <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">v</span><span class="special">[</span><span class="number">1</span><span class="special">]</span> <span class="special">==</span> <span class="number">20</span><span class="special">);</span>
+<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">v</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="special">==</span> <span class="number">10</span><span class="special">);</span> <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">v</span><span class="special">[</span><span class="number">1</span><span class="special">]</span> <span class="special">==</span> <span class="number">20</span><span class="special">);</span>
<span class="identifier">w</span><span class="special">.</span><span class="identifier">resize</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">size</span><span class="special">());</span>
<span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">&</span> <span class="identifier">offset</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">i</span><span class="special">)</span> <span class="special">{</span>
@@ -371,7 +370,7 @@
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">inc</span><span class="special">)</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">transform</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">w</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">inc</span><span class="special">);</span>
-<span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">w</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="special">==</span> <span class="number">16</span><span class="special">);</span> <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">w</span><span class="special">[</span><span class="number">1</span><span class="special">]</span> <span class="special">==</span> <span class="number">26</span><span class="special">);</span>
+<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">w</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="special">==</span> <span class="number">16</span><span class="special">);</span> <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">w</span><span class="special">[</span><span class="number">1</span><span class="special">]</span> <span class="special">==</span> <span class="number">26</span><span class="special">);</span>
<span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="identifier">bind</span><span class="special">&</span> <span class="identifier">inc</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">i</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">j</span><span class="special">)</span> <span class="special">{</span>
<span class="keyword">return</span> <span class="identifier">inc</span><span class="special">(</span><span class="identifier">i</span> <span class="special">+</span> <span class="identifier">j</span><span class="special">);</span> <span class="comment">// Call the other bound local function.</span>
@@ -379,7 +378,7 @@
<span class="identifier">offset</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">transform</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">w</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">inc_sum</span><span class="special">);</span>
-<span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">v</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="special">==</span> <span class="number">27</span><span class="special">);</span> <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">v</span><span class="special">[</span><span class="number">1</span><span class="special">]</span> <span class="special">==</span> <span class="number">47</span><span class="special">);</span>
+<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">v</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="special">==</span> <span class="number">27</span><span class="special">);</span> <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">v</span><span class="special">[</span><span class="number">1</span><span class="special">]</span> <span class="special">==</span> <span class="number">47</span><span class="special">);</span>
</pre>
<p>
</p>
@@ -477,7 +476,7 @@
<span class="identifier">BOOST_CONCEPT_ASSERT</span><span class="special">((</span><span class="identifier">Addable</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">remove_reference</span><span class="special"><</span>
<span class="identifier">BOOST_LOCAL_FUNCTION_TYPEOF</span><span class="special">(</span><span class="identifier">sum</span><span class="special">)>::</span><span class="identifier">type</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="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME_TPL</span><span class="special">(</span><span class="identifier">add</span><span class="special">)</span>
<span class="identifier">add</span><span class="special">(</span><span class="number">6</span><span class="special">);</span>
<span class="keyword">return</span> <span class="identifier">sum</span><span class="special">;</span>
@@ -564,15 +563,18 @@
</p>
<p>
</p>
-<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">adder</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">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>
<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 result types...</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="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="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>
@@ -622,23 +624,20 @@
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
- On C++03
- 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>
+ 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
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 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>
+ 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>
</li>
</ul></div>
<div class="important"><table border="0" summary="Important">
@@ -648,9 +647,8 @@
</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 C++03
- compliant code (because in all other cases this library will automatically
- take advantage of C++11
+ 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).
</p></td></tr>
@@ -735,11 +733,11 @@
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 <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> 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).
+ 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).
</p></td></tr>
</table></div>
</div>
@@ -761,35 +759,7 @@
(see also overload.cpp
):
</p>
<p>
-</p>
-<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">add_i</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">y</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">x</span> <span class="special">+</span> <span class="identifier">y</span><span class="special">;</span> <span class="special">}</span>
-
-<span class="identifier">BOOST_AUTO_TEST_CASE</span><span class="special">(</span><span class="identifier">test_overload</span><span class="special">)</span> <span class="special">{</span>
- <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_CHECK</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_CHECK</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_CHECK</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_CHECK</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>
-<span class="special">}</span>
-</pre>
-<p>
+ [overload]
</p>
</div>
<div class="section boost_localfunction_Advanced_Topics_exception_specifications">
@@ -841,7 +811,7 @@
Classifiers (<code class="computeroutput"><span class="keyword">auto</span></code> and <code class="computeroutput"><span class="keyword">register</span></code>)</a>
</h3></div></div></div>
<p>
- Local function parameters support the storage classifiers as usual in C++03.
+ Local function parameters support the storage classifiers as usual in __CPP03__.
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>
</p>
@@ -906,12 +876,14 @@
<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="identifier">BOOST_AUTO_TEST_CASE</span><span class="special">(</span><span class="identifier">test_same_line</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">BOOST_CHECK</span><span class="special">(</span><span class="identifier">dec</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="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="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>
@@ -989,8 +961,7 @@
<td>
<p>
This is not supported because local functions are implemented using
- local classes and C++03
- local classes cannot be templates.
+ local classes and __CPP03__ local classes cannot be templates.
</p>
</td>
</tr>
@@ -1025,10 +996,9 @@
<td>
<p>
Local functions can be specified <code class="computeroutput"><span class="keyword">inline</span></code>
- to improve the chances that C++03
- 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 C++03
+ 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
Topics</a> section).
</p>
@@ -1210,15 +1180,17 @@
<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="identifier">BOOST_AUTO_TEST_CASE</span><span class="special">(</span><span class="identifier">test_operator_error</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">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_CHECK</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="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>
<p>
@@ -1245,7 +1217,7 @@
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">validate</span><span class="special">)</span>
<span class="keyword">return</span> <span class="identifier">validate</span><span class="special">(</span><span class="identifier">x</span> <span class="special">+</span> <span class="identifier">y</span><span class="special">);</span>
-<span class="identifier">faliure</span><span class="special">:</span>
+<span class="identifier">failure</span><span class="special">:</span>
<span class="keyword">return</span> <span class="special">-</span><span class="number">1</span><span class="special">;</span>
<span class="special">}</span>
</pre>
@@ -1299,8 +1271,7 @@
<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 <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> functions. However, the library accepts bound variables,
+ by __CPP11_lambda__ functions. 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>
@@ -1312,12 +1283,11 @@
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 C++03
- but it is not needed on C++11
- (see [N2657])
+ 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 C++11
- compilers (even when the local function is not declared inline).
+ can be inlined on __CPP11__ 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
@@ -1331,13 +1301,11 @@
</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>
The <code class="computeroutput"><span class="keyword">auto</span></code> storage classifier
- 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.
+ 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__.
</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>
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-11 01:47:37 EDT (Wed, 11 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="../index.html" title="Chapter 1. Boost.LocalFunction 1.0.0">
-<link rel="prev" href="../BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX">
+<link rel="prev" href="Examples.html" title="Examples">
<link rel="next" href="No_Variadic_Macros.html" title="Annex: No Variadic Macros">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
@@ -20,7 +20,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
-<a accesskey="p" href="../BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="No_Variadic_Macros.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+<a accesskey="p" href="Examples.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="No_Variadic_Macros.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section boost_localfunction_Alternatives">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
@@ -189,9 +189,8 @@
</td>
<td>
<p>
- Yes. The C++03
- standard does not allow to pass local types as template parameters
- (see [N2657])
+ 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 <a class="link" href="Implementation.html" title="Annex: Implementation">Implementation</a>
section).
@@ -204,9 +203,8 @@
</td>
<td>
<p>
- No on C++03
- compilers (but yes on C++11
- compilers and some compilers like MSVC 8.0, see [N2657]).
+ No on __CPP03__ compilers (but yes on __CPP11__ compilers and some
+ compilers like MSVC 8.0, see [N2657]).
</p>
</td>
<td>
@@ -278,8 +276,7 @@
</td>
<td>
<p>
- No (C++11
- lambdas cannot be function templates).
+ No (__CPP11__ lambdas cannot be function templates).
</p>
</td>
<td>
@@ -304,39 +301,31 @@
<span class="bold"><strong>C++11 Lambda Function</strong></span>
</p>
<p>
- <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> functions have most of the features of this library (see also
+ __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>
section):
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
- <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> functions can be defined within expressions while this library
- local functions can only be defined at declaration scope.
+ __CPP11_lambda__ functions can be defined within expressions while this
+ library local functions can only be defined at declaration scope.
</li>
<li class="listitem">
- <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> functions are only supported by the C++11
- standard so they are not supported by all C++ compilers. This library local
- functions can be programmed also on C++03
- compilers (and they have performances comparable to <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> functions on C++11
- compilers).
+ __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).
</li>
<li class="listitem">
- <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> functions do not allow to bind variables in scope by constant
+ __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, <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> functions can bind a variable by constant only if the variable
- is <code class="computeroutput"><span class="identifier">CopyConstructible</span></code> and
- the binding requires a (potentially expensive) extra copy operation. Both
- constant reference and non-constant value binding are instead supported
- by this library. However, <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> 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>).
+ 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>).
</li>
</ul></div>
<p>
@@ -372,8 +361,8 @@
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span>
<span class="identifier">n</span> <span class="identifier">x</span><span class="special">(-</span><span class="number">1</span><span class="special">);</span>
- <span class="keyword">auto</span> <span class="identifier">f</span> <span class="special">=</span> <span class="special">[</span><span class="identifier">x</span><span class="special">](</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Error: x is non-copyable, but if</span>
- <span class="identifier">assert</span><span class="special">(</span> <span class="identifier">x</span><span class="special">.</span><span class="identifier">i</span> <span class="special">==</span> <span class="special">-</span><span class="number">1</span> <span class="special">);</span> <span class="comment">// bind `&x` then `x` is not constant.</span>
+ <span class="keyword">auto</span> <span class="identifier">f</span> <span class="special">=</span> <span class="special">[</span><span class="identifier">x</span><span class="special">](</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Error: x is non-copyable, but if</span>
+ <span class="identifier">assert</span><span class="special">(</span><span class="identifier">x</span><span class="special">.</span><span class="identifier">i</span> <span class="special">==</span> <span class="special">-</span><span class="number">1</span><span class="special">);</span> <span class="comment">// bind `&x` then `x` is not constant.</span>
<span class="special">};</span>
<span class="identifier">f</span><span class="special">();</span>
@@ -390,12 +379,13 @@
<span class="keyword">int</span> <span class="identifier">i</span><span class="special">;</span>
<span class="identifier">n</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">_i</span><span class="special">):</span> <span class="identifier">i</span><span class="special">(</span><span class="identifier">_i</span><span class="special">)</span> <span class="special">{}</span>
<span class="special">};</span>
+<span class="identifier">BOOST_TYPEOF_REGISTER_TYPE</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span> <span class="comment">// Register for `bind& x` below.</span>
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> <span class="special">{</span>
<span class="identifier">n</span> <span class="identifier">x</span><span class="special">(-</span><span class="number">1</span><span class="special">);</span>
<span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">&</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// OK: No copy</span>
- <span class="identifier">assert</span><span class="special">(</span> <span class="identifier">x</span><span class="special">.</span><span class="identifier">i</span> <span class="special">==</span> <span class="special">-</span><span class="number">1</span> <span class="special">);</span> <span class="comment">// and constant.</span>
+ <span class="identifier">assert</span><span class="special">(</span><span class="identifier">x</span><span class="special">.</span><span class="identifier">i</span> <span class="special">==</span> <span class="special">-</span><span class="number">1</span><span class="special">);</span> <span class="comment">// and constant.</span>
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">f</span><span class="special">)</span>
<span class="identifier">f</span><span class="special">();</span>
@@ -412,10 +402,7 @@
and expensive_copy_local_function.cpp
):
</p>
<div class="informaltable"><table class="table">
-<colgroup>
-<col>
-<col>
-</colgroup>
+<colgroup><col></colgroup>
<thead><tr>
<th>
<p>
@@ -428,66 +415,27 @@
</p>
</th>
</tr></thead>
-<tbody><tr>
-<td>
+<tbody>
+<tr><td>
<p>
-</p>
-<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">struct</span> <span class="identifier">n</span> <span class="special">{</span>
- <span class="keyword">int</span> <span class="identifier">i</span><span class="special">;</span>
- <span class="identifier">n</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">_i</span><span class="special">):</span> <span class="identifier">i</span><span class="special">(</span><span class="identifier">_i</span><span class="special">)</span> <span class="special">{}</span>
- <span class="identifier">n</span><span class="special">(</span><span class="identifier">n</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">x</span><span class="special">):</span> <span class="identifier">i</span><span class="special">(</span><span class="identifier">x</span><span class="special">.</span><span class="identifier">i</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Some time consuming copy.</span>
- <span class="keyword">for</span> <span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</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>
+ [expensive_copy_lambda
</p>
- </td>
-<td>
+ </td></tr>
+<tr><td>
<p>
-</p>
-<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">struct</span> <span class="identifier">n</span> <span class="special">{</span>
- <span class="keyword">int</span> <span class="identifier">i</span><span class="special">;</span>
- <span class="identifier">n</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">_i</span><span class="special">):</span> <span class="identifier">i</span><span class="special">(</span><span class="identifier">_i</span><span class="special">)</span> <span class="special">{}</span>
- <span class="identifier">n</span><span class="special">(</span><span class="identifier">n</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">x</span><span class="special">):</span> <span class="identifier">i</span><span class="special">(</span><span class="identifier">x</span><span class="special">.</span><span class="identifier">i</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Some time consuming copy.</span>
- <span class="keyword">for</span> <span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</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">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>
- <span class="identifier">assert</span><span class="special">(</span> <span class="identifier">x</span><span class="special">.</span><span class="identifier">i</span> <span class="special">==</span> <span class="special">-</span><span class="number">1</span> <span class="special">);</span> <span class="comment">// and constant.</span>
- <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">f</span><span class="special">)</span>
- <span class="identifier">f</span><span class="special">();</span>
-
- <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
-<span class="special">}</span>
-</pre>
-<p>
+ expensive_copy_local_function
</p>
- </td>
-</tr></tbody>
+ </td></tr>
+</tbody>
</table></div>
<p>
- When constant binding functionality is needed for <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> functions, the best alternative might be to bind an extra local
- variable declared constant and initialized to the original variable (for example,
- <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">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>
+ ]
+ </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>
@@ -522,7 +470,7 @@
<td>
<p>
</p>
-<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="special">{</span>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span>
<span class="keyword">int</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span>
<span class="keyword">struct</span> <span class="identifier">local_add</span> <span class="special">{</span> <span class="comment">// Unfortunately, boilerplate code to program the class.</span>
@@ -541,7 +489,8 @@
<span class="comment">// Unfortunately, cannot pass as template parameter to `std::for_each`.</span>
<span class="keyword">for</span><span class="special">(</span><span class="identifier">size_t</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">2</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">add</span><span class="special">(</span><span class="identifier">nums</span><span class="special">[</span><span class="identifier">i</span><span class="special">]);</span>
- <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">sum</span> <span class="special">==</span> <span class="number">60</span><span class="special">);</span>
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">sum</span> <span class="special">==</span> <span class="number">60</span><span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span><span class="special">();</span>
<span class="special">}</span>
</pre>
<p>
@@ -550,7 +499,7 @@
<td>
<p>
</p>
-<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="special">{</span> <span class="comment">// Some local scope.</span>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Some local scope.</span>
<span class="keyword">int</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span> <span class="comment">// Variables in scope to bind.</span>
<span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">factor</span><span class="special">,</span> <span class="identifier">bind</span><span class="special">&</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>
@@ -561,7 +510,8 @@
<span class="keyword">int</span> <span class="identifier">nums</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span><span class="number">2</span><span class="special">,</span> <span class="number">3</span><span class="special">};</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">nums</span><span class="special">,</span> <span class="identifier">nums</span> <span class="special">+</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">add</span><span class="special">);</span> <span class="comment">// Pass it to an algorithm.</span>
- <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">sum</span> <span class="special">==</span> <span class="number">60</span><span class="special">);</span> <span class="comment">// Assert final summation value.</span>
+ <span class="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>
@@ -610,7 +560,7 @@
<span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">factor</span><span class="special">;</span> <span class="comment">// Make `factor` constant.</span>
<span class="special">};</span>
-<span class="identifier">BOOST_AUTO_TEST_CASE</span><span class="special">(</span><span class="identifier">test_add_global_functor</span><span class="special">)</span> <span class="special">{</span>
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span>
<span class="keyword">int</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span>
<span class="identifier">global_add</span> <span class="identifier">add</span><span class="special">(</span><span class="identifier">sum</span><span class="special">,</span> <span class="identifier">factor</span><span class="special">);</span>
@@ -619,7 +569,8 @@
<span class="keyword">int</span> <span class="identifier">nums</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span><span class="number">2</span><span class="special">,</span> <span class="number">3</span><span class="special">};</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">nums</span><span class="special">,</span> <span class="identifier">nums</span> <span class="special">+</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">add</span><span class="special">);</span> <span class="comment">// Passed as template parameter.</span>
- <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">sum</span> <span class="special">==</span> <span class="number">60</span><span class="special">);</span>
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">sum</span> <span class="special">==</span> <span class="number">60</span><span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span><span class="special">();</span>
<span class="special">}</span>
</pre>
<p>
@@ -628,7 +579,7 @@
<td>
<p>
</p>
-<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="special">{</span> <span class="comment">// Some local scope.</span>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Some local scope.</span>
<span class="keyword">int</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span> <span class="comment">// Variables in scope to bind.</span>
<span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">factor</span><span class="special">,</span> <span class="identifier">bind</span><span class="special">&</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>
@@ -639,7 +590,8 @@
<span class="keyword">int</span> <span class="identifier">nums</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span><span class="number">2</span><span class="special">,</span> <span class="number">3</span><span class="special">};</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">nums</span><span class="special">,</span> <span class="identifier">nums</span> <span class="special">+</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">add</span><span class="special">);</span> <span class="comment">// Pass it to an algorithm.</span>
- <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">sum</span> <span class="special">==</span> <span class="number">60</span><span class="special">);</span> <span class="comment">// Assert final summation value.</span>
+ <span class="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>
@@ -680,7 +632,7 @@
<td>
<p>
</p>
-<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="special">{</span>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span>
<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">let</span><span class="special">;</span>
<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">local_names</span><span class="special">::</span><span class="identifier">_f</span><span class="special">;</span>
<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">cref</span><span class="special">;</span>
@@ -696,7 +648,8 @@
<span class="identifier">ref</span><span class="special">(</span><span class="identifier">sum</span><span class="special">)</span> <span class="special">+=</span> <span class="identifier">_f</span> <span class="special">*</span> <span class="identifier">_1</span><span class="special">,</span> <span class="identifier">_1</span> <span class="comment">// Access `sum` by reference.</span>
<span class="special">]);</span>
- <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">sum</span> <span class="special">==</span> <span class="number">60</span><span class="special">);</span>
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">sum</span> <span class="special">==</span> <span class="number">60</span><span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span><span class="special">();</span>
<span class="special">}</span>
</pre>
<p>
@@ -705,7 +658,7 @@
<td>
<p>
</p>
-<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="special">{</span> <span class="comment">// Some local scope.</span>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Some local scope.</span>
<span class="keyword">int</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span> <span class="comment">// Variables in scope to bind.</span>
<span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">factor</span><span class="special">,</span> <span class="identifier">bind</span><span class="special">&</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>
@@ -716,7 +669,8 @@
<span class="keyword">int</span> <span class="identifier">nums</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span><span class="number">2</span><span class="special">,</span> <span class="number">3</span><span class="special">};</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">nums</span><span class="special">,</span> <span class="identifier">nums</span> <span class="special">+</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">add</span><span class="special">);</span> <span class="comment">// Pass it to an algorithm.</span>
- <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">sum</span> <span class="special">==</span> <span class="number">60</span><span class="special">);</span> <span class="comment">// Assert final summation value.</span>
+ <span class="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>
@@ -740,13 +694,12 @@
</p>
<p>
Overall, this library has compile-times and generates binary sizes similar
- to the ones of the other approaches. This library run-times on C++03
- compilers were measured to be larger than other approaches when compiler optimization
+ 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 <code class="computeroutput"><span class="identifier">bjam</span> <span class="identifier">release</span>
<span class="special">...</span></code>). However, on compilers that allow
to pass local types as template parameters (e.g., MSVC 8.0 or GCC 4.5.3 with
- C++11 features
- enabled <code class="literal">-std=c++0x</code>, see also [N2657])
+ __CPP11__ features enabled <code class="literal">-std=c++0x</code>, see also [N2657])
this library automatically generates optimized code that runs as fast as the
fastest of the other approaches (see the "Boost.LocalFunction" approach
below). When this library local function is specified <code class="computeroutput"><span class="keyword">inline</span></code>
@@ -768,8 +721,7 @@
</tr>
<tr><td align="left" valign="top"><p>
The run-time performances of this library local functions are explained because
- on C++03
- compliant compilers (e.g., GCC 4.5.3 without <code class="literal">-std=c++0x</code>)
+ 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]
and the <a class="link" href="Implementation.html" title="Annex: Implementation">Implementation</a>
@@ -779,20 +731,19 @@
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 C++11
- features enabled <code class="literal">-std=c++0x</code>) because this library does
- not have to use the extra function pointer to implement the local function
- call (it directly passes the local class type as template parameter).
+ 8.0 or GCC 4.5.3 with __CPP11__ features enabled <code class="literal">-std=c++0x</code>)
+ because this library does not have to use the extra function pointer to implement
+ the local function call (it directly passes the local class type as template
+ parameter).
</p></td></tr>
</table></div>
<p>
- 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.
+ 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.
</p>
<p>
Finally, note that only a very simple local function body with just a single
@@ -886,8 +837,7 @@
</td>
<td>
<p>
- C++11
- Lambda Function <sup>[<a name="boost_localfunction.Alternatives.f0" href="#ftn.boost_localfunction.Alternatives.f0" class="footnote">a</a>]</sup>
+ __CPP11__ Lambda Function <sup>[<a name="boost_localfunction.Alternatives.f0" href="#ftn.boost_localfunction.Alternatives.f0" class="footnote">a</a>]</sup>
</p>
</td>
<td>
@@ -949,8 +899,7 @@
</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 C++11
- compilers.
+ Measurements available only for __CPP11__ compilers.
</p></div></td></tr></tbody>
</table></div>
<div class="informaltable"><table class="table">
@@ -983,8 +932,7 @@
<thead><tr><th>
<p>
MSVC 8.0 With "Local Types as Template Parameters" (Without
- C++11
- Lambdas)
+ __CPP11__ Lambdas)
</p>
</th></tr></thead>
<tbody>
@@ -1007,9 +955,8 @@
<colgroup><col></colgroup>
<thead><tr><th>
<p>
- GCC 4.3.4 With C++03
- Only (Without C++11
- Lambdas and Without "Local Types as Template Parameters")
+ GCC 4.3.4 With __CPP03__ Only (Without __CPP11__ Lambdas and Without
+ "Local Types as Template Parameters")
</p>
</th></tr></thead>
<tbody>
@@ -1041,7 +988,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
-<a accesskey="p" href="../BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="No_Variadic_Macros.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+<a accesskey="p" href="Examples.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="No_Variadic_Macros.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
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-11 01:47:37 EDT (Wed, 11 Apr 2012)
@@ -7,7 +7,7 @@
<link rel="home" href="../index.html" title="Chapter 1. Boost.LocalFunction 1.0.0">
<link rel="up" href="../index.html" title="Chapter 1. Boost.LocalFunction 1.0.0">
<link rel="prev" href="Advanced_Topics.html" title="Advanced Topics">
-<link rel="next" href="../reference.html" title="Reference">
+<link rel="next" href="Alternatives.html" title="Annex: Alternatives">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
@@ -20,7 +20,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
-<a accesskey="p" href="Advanced_Topics.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../reference.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+<a accesskey="p" href="Advanced_Topics.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="Alternatives.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section boost_localfunction_Examples">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
@@ -50,8 +50,7 @@
<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 C++11
- support.
+ lambda functions for GCC compilers even without __CPP11__ support.
</p>
<div class="warning"><table border="0" summary="Warning">
<tr>
@@ -60,8 +59,7 @@
</tr>
<tr><td align="left" valign="top"><p>
This code only works on compilers that support the statement expression
- GCC extension or that support <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> functions.
+ GCC extension or that support __CPP11_lambda__ functions.
</p></td></tr>
</table></div>
<p>
@@ -104,49 +102,35 @@
</td>
<td>
<p>
-</p>
-<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">int</span> <span class="identifier">val</span> <span class="special">=</span> <span class="number">2</span><span class="special">;</span>
-<span class="keyword">int</span> <span class="identifier">nums</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span><span class="number">1</span><span class="special">,</span> <span class="number">2</span><span class="special">,</span> <span class="number">3</span><span class="special">};</span>
-<span class="keyword">int</span><span class="special">*</span> <span class="identifier">end</span> <span class="special">=</span> <span class="identifier">nums</span> <span class="special">+</span> <span class="number">3</span><span class="special">;</span>
-
-<span class="keyword">int</span><span class="special">*</span> <span class="identifier">iter</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">find_if</span><span class="special">(</span><span class="identifier">nums</span><span class="special">,</span> <span class="identifier">end</span><span class="special">,</span>
- <span class="special">[</span><span class="identifier">val</span><span class="special">](</span><span class="keyword">int</span> <span class="identifier">num</span><span class="special">)</span> <span class="special">-></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>
+ [gcc_lambda_cxx11
</p>
</td>
</tr></tbody>
</table></div>
<p>
+ ]
+ </p>
+<p>
Where the macros are defined in gcc_lambda.hpp
.
</p>
<p>
This is possible because GCC statement expressions allow to use declaration
statements within expressions and therefore to declare a local function within
- an expression. The macros automatically detect if the compiler supports
- <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> functions in which case the implementation uses native lambdas
- instead of local functions in statement expressions. However, <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> 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 <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> <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 <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> <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 <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> short-hand binds <code class="computeroutput"><span class="special">&</span></code>
+ 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>
is optional and it is assumed <code class="computeroutput"><span class="keyword">void</span></code>
- when it is not specified (same as with <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> functions).
+ when it is not specified (same as with __CPP11_lambda__ functions).
</p>
</div>
<div class="section boost_localfunction_Examples_constant_blocks">
@@ -236,14 +220,14 @@
were all specified variables are constant.
</p>
<p>
- Unfortunately, constant blocks cannot be implemented with <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> 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
- <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> 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 __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>,
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>
@@ -375,7 +359,7 @@
<td>
<p>
</p>
-<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">BOOST_AUTO_TEST_CASE</span><span class="special">(</span><span class="identifier">test_phoenix_factorial_local</span><span class="special">)</span> <span class="special">{</span>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span>
<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">arg_names</span><span class="special">::</span><span class="identifier">arg1</span><span class="special">;</span>
<span class="keyword">int</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Unfortunately, monomorphic.</span>
@@ -386,8 +370,9 @@
<span class="identifier">factorial</span><span class="special">(</span><span class="identifier">factorial_impl</span><span class="special">);</span> <span class="comment">// Phoenix function from local function.</span>
<span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">4</span><span class="special">;</span>
- <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">factorial</span><span class="special">(</span><span class="identifier">i</span><span class="special">)()</span> <span class="special">==</span> <span class="number">24</span><span class="special">);</span> <span class="comment">// Call.</span>
- <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">factorial</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">)(</span><span class="identifier">i</span><span class="special">)</span> <span class="special">==</span> <span class="number">24</span><span class="special">);</span> <span class="comment">// Lazy call.</span>
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">factorial</span><span class="special">(</span><span class="identifier">i</span><span class="special">)()</span> <span class="special">==</span> <span class="number">24</span><span class="special">);</span> <span class="comment">// Call.</span>
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">factorial</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">)(</span><span class="identifier">i</span><span class="special">)</span> <span class="special">==</span> <span class="number">24</span><span class="special">);</span> <span class="comment">// Lazy call.</span>
+ <span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span><span class="special">();</span>
<span class="special">}</span>
</pre>
<p>
@@ -412,14 +397,15 @@
<span class="special">}</span>
<span class="special">};</span>
-<span class="identifier">BOOST_AUTO_TEST_CASE</span><span class="special">(</span><span class="identifier">test_phoenix_factorial</span><span class="special">)</span> <span class="special">{</span>
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span>
<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">arg_names</span><span class="special">::</span><span class="identifier">arg1</span><span class="special">;</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">phoenix</span><span class="special">::</span><span class="identifier">function</span><span class="special"><</span><span class="identifier">factorial_impl</span><span class="special">></span> <span class="identifier">factorial</span><span class="special">;</span>
<span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">4</span><span class="special">;</span>
- <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">factorial</span><span class="special">(</span><span class="identifier">i</span><span class="special">)()</span> <span class="special">==</span> <span class="number">24</span><span class="special">);</span> <span class="comment">// Call.</span>
- <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">factorial</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">)(</span><span class="identifier">i</span><span class="special">)</span> <span class="special">==</span> <span class="number">24</span><span class="special">);</span> <span class="comment">// Lazy call.</span>
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">factorial</span><span class="special">(</span><span class="identifier">i</span><span class="special">)()</span> <span class="special">==</span> <span class="number">24</span><span class="special">);</span> <span class="comment">// Call.</span>
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">factorial</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">)(</span><span class="identifier">i</span><span class="special">)</span> <span class="special">==</span> <span class="number">24</span><span class="special">);</span> <span class="comment">// Lazy call.</span>
+ <span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span><span class="special">();</span>
<span class="special">}</span>
</pre>
<p>
@@ -553,9 +539,8 @@
<td>
<p>
This example is adapted from [N2550]
- (<a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> 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>.
+ (__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>.
</p>
</td>
</tr>
@@ -568,8 +553,7 @@
<td>
<p>
This example is adapted from [N2529]
- (<a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> functions): It binds the object in scope <code class="computeroutput"><span class="keyword">this</span></code> to a local function.
+ (__CPP11_lambda__ functions): It binds the object in scope <code class="computeroutput"><span class="keyword">this</span></code> to a local function.
</p>
</td>
</tr>
@@ -579,14 +563,16 @@
<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, <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> 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>
+ 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>
(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>
<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 C++11).
+ classes cannot be templates in C++ (not even in __CPP11__).
</p></div>
</div>
</div>
@@ -601,7 +587,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
-<a accesskey="p" href="Advanced_Topics.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../reference.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+<a accesskey="p" href="Advanced_Topics.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="Alternatives.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
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-11 01:47:37 EDT (Wed, 11 Apr 2012)
@@ -32,7 +32,6 @@
<dt><span class="section"><a href="Getting_Started.html#boost_localfunction.Getting_Started.compilers_and_platforms">Compilers
and Platforms</a></span></dt>
<dt><span class="section">Installation</span></dt>
-<dt><span class="section">Configuration</span></dt>
</dl></div>
<p>
This section explains how programmers can setup their system to use this library.
@@ -58,12 +57,12 @@
of this library.
</p>
<p>
- In some of the examples presented in this documentation, the Boost.Test
- macro <code class="computeroutput"><span class="identifier">BOOST_CHECK</span></code> is used
- equivalently to <code class="computeroutput"><span class="identifier">assert</span></code> and
- the Boost.Test macro
- <code class="computeroutput"><span class="identifier">BOOST_AUTO_TEST_CASE</span></code> is used
- equivalently to <code class="computeroutput"><span class="identifier">main</span></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>
+ 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>
</p>
</div>
<div class="section boost_localfunction_Getting_Started_compilers_and_platforms">
@@ -139,19 +138,11 @@
Any symbol prefixed by <code class="computeroutput"><span class="identifier">BOOST_LOCAL_FUNCTION_AUX_</span><span class="special">...</span></code> or <code class="computeroutput"><span class="identifier">BOOST_LOCAL_FUNCTION_DETAIL_</span><span class="special">...</span></code> (regardless of its namespace).
</li>
</ul></div>
-</div>
-<div class="section boost_localfunction_Getting_Started_configuration">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="boost_localfunction.Getting_Started.configuration"></a><a class="link" href="Getting_Started.html#boost_localfunction.Getting_Started.configuration" title="Configuration">Configuration</a>
-</h3></div></div></div>
<p>
Some of the library behaviour can be changed at compile-time by defining
special <span class="emphasis"><em>configuration macros</em></span>. If a configuration macro
is left undefined, the library will use an appropriate default value for
- it.
- </p>
-<p>
- All configuration macros are defined in the header file <code class="computeroutput"><a class="link" href="../reference.html#header.boost.local_function.config_hpp" title="Header <boost/local_function/config.hpp>">boost/local_function/config.hpp</a></code>.
+ it. All configuration macros are defined in the header file <code class="computeroutput"><a class="link" href="../reference.html#header.boost.local_function.config_hpp" title="Header <boost/local_function/config.hpp>">boost/local_function/config.hpp</a></code>.
It is strongly recommended not to change the library configuration macro
definitions unless strictly necessary.
</p>
@@ -159,9 +150,9 @@
<div class="footnotes">
<br><hr width="100" align="left">
<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.Getting_Started.this_documentation.f0" href="#boost_localfunction.Getting_Started.this_documentation.f0" class="para">3</a>] </sup>
- <span class="bold"><strong>Rationale.</strong></span> Using Boost.Test
- allows to add the documentation examples to the library regression tests
- so to make sure that the listed examples always compile and run correctly.
+ <span class="bold"><strong>Rationale.</strong></span> Using Boost.Detail/LightweightTest
+ allows to add the examples to the library regression tests so to make sure
+ that they always compile and run correctly.
</p></div>
<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.Getting_Started.installation.f0" href="#boost_localfunction.Getting_Started.installation.f0" class="para">4</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> This library concatenates symbols
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-11 01:47:37 EDT (Wed, 11 Apr 2012)
@@ -7,7 +7,7 @@
<link rel="home" href="../index.html" title="Chapter 1. Boost.LocalFunction 1.0.0">
<link rel="up" href="../index.html" title="Chapter 1. Boost.LocalFunction 1.0.0">
<link rel="prev" href="No_Variadic_Macros.html" title="Annex: No Variadic Macros">
-<link rel="next" href="Release_Notes.html" title="Release Notes">
+<link rel="next" href="../reference.html" title="Reference">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
@@ -20,7 +20,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
-<a accesskey="p" href="No_Variadic_Macros.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="Release_Notes.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+<a accesskey="p" href="No_Variadic_Macros.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../reference.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section boost_localfunction_Implementation">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
@@ -49,11 +49,10 @@
</h6>
<p>
This library uses a local class to implement the local function object. However,
- 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]).
+ 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]).
To work around this limitation, this library investigated the following two
"tricks" (both tricks can be extended to support eventual function
default parameters):
@@ -78,8 +77,7 @@
</p>
<p>
</p>
-<pre class="programlisting"><span class="preprocessor">#define</span> <span class="identifier">BOOST_TEST_MODULE</span> <span class="identifier">TestImplTparamTricks</span>
-<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">test</span><span class="special">/</span><span class="identifier">unit_test</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">detail</span><span class="special">/</span><span class="identifier">lightweight_test</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span>
@@ -106,7 +104,7 @@
<span class="identifier">interface</span><span class="special">*</span> <span class="identifier">func_</span><span class="special">;</span>
<span class="special">};</span>
-<span class="identifier">BOOST_AUTO_TEST_CASE</span><span class="special">(</span><span class="identifier">test_impl_tparam_tricks</span><span class="special">)</span> <span class="special">{</span>
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span>
<span class="keyword">int</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span>
<span class="comment">// Local class for local function.</span>
@@ -138,7 +136,8 @@
<span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">add_casting</span><span class="special">);</span> <span class="comment">// OK.</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">add_virtual</span><span class="special">);</span> <span class="comment">// OK.</span>
- <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">sum</span> <span class="special">==</span> <span class="number">200</span><span class="special">);</span>
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">sum</span> <span class="special">==</span> <span class="number">200</span><span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span><span class="special">();</span>
<span class="special">}</span>
</pre>
<p>
@@ -152,8 +151,7 @@
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, C++11,
- etc, see [N2657]),
+ 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
@@ -184,8 +182,7 @@
<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">detail</span><span class="special">/</span><span class="identifier">preprocessor</span><span class="special">/</span><span class="identifier">keyword</span><span class="special">/</span><span class="identifier">thisunderscore</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
<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">detail</span><span class="special">/</span><span class="identifier">preprocessor</span><span class="special">/</span><span class="identifier">keyword</span><span class="special">/</span><span class="keyword">const</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
<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">detail</span><span class="special">/</span><span class="identifier">preprocessor</span><span class="special">/</span><span class="identifier">keyword</span><span class="special">/</span><span class="identifier">bind</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
-<span class="preprocessor">#define</span> <span class="identifier">BOOST_TEST_MODULE</span> <span class="identifier">TestImplPpKeyword</span>
-<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">test</span><span class="special">/</span><span class="identifier">unit_test</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
+<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">detail</span><span class="special">/</span><span class="identifier">lightweight_test</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
<span class="comment">// Expand to 1 if space-separated tokens end with `this_`, 0 otherwise.</span>
<span class="preprocessor">#define</span> <span class="identifier">IS_THIS_BACK</span><span class="special">(</span><span class="identifier">tokens</span><span class="special">)</span> <span class="special">\</span>
@@ -195,9 +192,10 @@
<span class="identifier">tokens</span> <span class="special">\</span>
<span class="special">)))</span>
-<span class="identifier">BOOST_AUTO_TEST_CASE</span><span class="special">(</span><span class="identifier">test_impl_pp_keyword</span><span class="special">)</span> <span class="special">{</span>
- <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">IS_THIS_BACK</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">this_</span><span class="special">)</span> <span class="special">==</span> <span class="number">1</span><span class="special">);</span>
- <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">IS_THIS_BACK</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">&</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">==</span> <span class="number">0</span><span class="special">);</span>
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">IS_THIS_BACK</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">this_</span><span class="special">)</span> <span class="special">==</span> <span class="number">1</span><span class="special">);</span>
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">IS_THIS_BACK</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span><span class="special">&</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">==</span> <span class="number">0</span><span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span><span class="special">();</span>
<span class="special">}</span>
</pre>
<p>
@@ -222,7 +220,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
-<a accesskey="p" href="No_Variadic_Macros.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="Release_Notes.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+<a accesskey="p" href="No_Variadic_Macros.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../reference.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
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-11 01:47:37 EDT (Wed, 11 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 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
+ 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
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>
@@ -57,7 +57,7 @@
</p>
<p>
</p>
-<pre class="programlisting"><span class="special">{</span>
+<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span>
<span class="keyword">int</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span>
<span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">factor</span><span class="special">)</span> <span class="special">(</span><span class="identifier">bind</span><span class="special">&</span> <span class="identifier">sum</span><span class="special">)</span> <span class="special">(</span><span class="keyword">int</span> <span class="identifier">num</span><span class="special">)</span> <span class="special">)</span> <span class="special">{</span>
@@ -68,7 +68,8 @@
<span class="keyword">int</span> <span class="identifier">nums</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span><span class="number">2</span><span class="special">,</span> <span class="number">3</span><span class="special">};</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">nums</span><span class="special">,</span> <span class="identifier">nums</span> <span class="special">+</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">add</span><span class="special">);</span>
- <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">sum</span> <span class="special">==</span> <span class="number">60</span><span class="special">);</span>
+ <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">sum</span> <span class="special">==</span> <span class="number">60</span><span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">report_errors</span><span class="special">();</span>
<span class="special">}</span>
</pre>
<p>
@@ -79,7 +80,7 @@
</p>
<p>
</p>
-<pre class="programlisting"><span class="special">{</span> <span class="comment">// Some local scope.</span>
+<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Some local scope.</span>
<span class="keyword">int</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span> <span class="comment">// Variables in scope to bind.</span>
<span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">factor</span><span class="special">,</span> <span class="identifier">bind</span><span class="special">&</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>
@@ -90,7 +91,8 @@
<span class="keyword">int</span> <span class="identifier">nums</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span><span class="number">2</span><span class="special">,</span> <span class="number">3</span><span class="special">};</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">nums</span><span class="special">,</span> <span class="identifier">nums</span> <span class="special">+</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">add</span><span class="special">);</span> <span class="comment">// Pass it to an algorithm.</span>
- <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">sum</span> <span class="special">==</span> <span class="number">60</span><span class="special">);</span> <span class="comment">// Assert final summation value.</span>
+ <span class="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>
@@ -107,7 +109,7 @@
<span class="keyword">return</span> <span class="number">10</span><span class="special">;</span>
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">ten</span><span class="special">)</span>
-<span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">ten</span><span class="special">()</span> <span class="special">==</span> <span class="number">10</span><span class="special">);</span>
+<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">ten</span><span class="special">()</span> <span class="special">==</span> <span class="number">10</span><span class="special">);</span>
</pre>
<p>
</p>
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-11 01:47:37 EDT (Wed, 11 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="../index.html" title="Chapter 1. Boost.LocalFunction 1.0.0">
-<link rel="prev" href="Implementation.html" title="Annex: Implementation">
+<link rel="prev" href="../BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS">
<link rel="next" href="Bibliography.html" title="Bibliography">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
@@ -20,7 +20,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
-<a accesskey="p" href="Implementation.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="Bibliography.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+<a accesskey="p" href="../BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="Bibliography.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section boost_localfunction_Release_Notes">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
@@ -151,7 +151,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
-<a accesskey="p" href="Implementation.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="Bibliography.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+<a accesskey="p" href="../BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="Bibliography.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
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-11 01:47:37 EDT (Wed, 11 Apr 2012)
@@ -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 <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> functions which can instead be declared also within expressions):
+ with respect to __CPP11_lambda__ functions 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>
@@ -92,7 +92,7 @@
<span class="keyword">return</span> <span class="identifier">x</span> <span class="special">+</span> <span class="identifier">y</span><span class="special">;</span>
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">add</span><span class="special">)</span>
-<span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">add</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="number">2</span><span class="special">)</span> <span class="special">==</span> <span class="number">3</span><span class="special">);</span> <span class="comment">// Local function call.</span>
+<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">add</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="number">2</span><span class="special">)</span> <span class="special">==</span> <span class="number">3</span><span class="special">);</span> <span class="comment">// Local function call.</span>
</pre>
<p>
</p>
@@ -113,7 +113,7 @@
<span class="keyword">return</span> <span class="number">10</span><span class="special">;</span>
<span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">ten</span><span class="special">)</span>
-<span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">ten</span><span class="special">()</span> <span class="special">==</span> <span class="number">10</span><span class="special">);</span>
+<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">ten</span><span class="special">()</span> <span class="special">==</span> <span class="number">10</span><span class="special">);</span>
</pre>
<p>
</p>
@@ -202,8 +202,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 <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> 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 __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>
</li>
<li class="listitem">
If a bound variable was declared as a reference in the enclosing scope,
@@ -231,7 +231,7 @@
</p>
<p>
</p>
-<pre class="programlisting"><span class="special">{</span> <span class="comment">// Some local scope.</span>
+<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Some local scope.</span>
<span class="keyword">int</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span> <span class="comment">// Variables in scope to bind.</span>
<span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">factor</span><span class="special">,</span> <span class="identifier">bind</span><span class="special">&</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>
@@ -242,7 +242,8 @@
<span class="keyword">int</span> <span class="identifier">nums</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span><span class="number">2</span><span class="special">,</span> <span class="number">3</span><span class="special">};</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">nums</span><span class="special">,</span> <span class="identifier">nums</span> <span class="special">+</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">add</span><span class="special">);</span> <span class="comment">// Pass it to an algorithm.</span>
- <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">sum</span> <span class="special">==</span> <span class="number">60</span><span class="special">);</span> <span class="comment">// Assert final summation value.</span>
+ <span class="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>
@@ -377,10 +378,10 @@
<span class="identifier">T</span> <span class="identifier">total</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">T</span><span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">T</span><span class="special">&</span> <span class="identifier">y</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">T</span><span class="special">&</span> <span class="identifier">z</span><span class="special">)</span> <span class="special">{</span>
<span class="identifier">T</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="identifier">T</span><span class="special">(),</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span>
- <span class="comment">// Using the `..._TPL` macro.</span>
+ <span class="comment">// Must use the `..._TPL` macros within templates.</span>
<span class="identifier">T</span> <span class="identifier">BOOST_LOCAL_FUNCTION_TPL</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">factor</span><span class="special">,</span> <span class="identifier">bind</span><span class="special">&</span> <span class="identifier">sum</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">num</span><span class="special">)</span> <span class="special">{</span>
<span class="keyword">return</span> <span class="identifier">sum</span> <span class="special">+=</span> <span class="identifier">factor</span> <span class="special">*</span> <span class="identifier">num</span><span class="special">;</span>
- <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="identifier">add</span><span class="special">)</span>
+ <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME_TPL</span><span class="special">(</span><span class="identifier">add</span><span class="special">)</span>
<span class="identifier">add</span><span class="special">(</span><span class="identifier">x</span><span class="special">);</span>
<span class="identifier">T</span> <span class="identifier">nums</span><span class="special">[</span><span class="number">2</span><span class="special">];</span> <span class="identifier">nums</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="special">=</span> <span class="identifier">y</span><span class="special">;</span> <span class="identifier">nums</span><span class="special">[</span><span class="number">1</span><span class="special">]</span> <span class="special">=</span> <span class="identifier">z</span><span class="special">;</span>
@@ -411,9 +412,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 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
+ <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
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.
@@ -519,8 +520,8 @@
<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 C++03
- does not allow to use <code class="computeroutput"><span class="keyword">typename</span></code>
+ 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>
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-11 01:47:37 EDT (Wed, 11 Apr 2012)
@@ -45,7 +45,6 @@
<dt><span class="section"><a href="boost_localfunction/Getting_Started.html#boost_localfunction.Getting_Started.compilers_and_platforms">Compilers
and Platforms</a></span></dt>
<dt><span class="section">Installation</span></dt>
-<dt><span class="section">Configuration</span></dt>
</dl></dd>
<dt><span class="section">Tutorial</span></dt>
<dd><dl>
@@ -61,8 +60,8 @@
Parameters</a></span></dt>
<dt><span class="section"><a href="boost_localfunction/Advanced_Topics.html#boost_localfunction.Advanced_Topics.commas_and_symbols_in_macros">Commas
and Symbols in Macros</a></span></dt>
-<dt><span class="section"><a href="boost_localfunction/Advanced_Topics.html#boost_localfunction.Advanced_Topics.assigning_and_returning">Assigning
- and Returning</a></span></dt>
+<dt><span class="section"><a href="boost_localfunction/Advanced_Topics.html#boost_localfunction.Advanced_Topics.assignments_and_returns">Assignments
+ and Returns</a></span></dt>
<dt><span class="section">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>
@@ -94,15 +93,15 @@
Nested Functions</a></span></dt>
<dt><span class="section">N-Papers</span></dt>
</dl></dd>
+<dt><span class="section">Annex: Alternatives</span></dt>
+<dt><span class="section"><a href="boost_localfunction/No_Variadic_Macros.html">Annex: No Variadic
+ Macros</a></span></dt>
+<dt><span class="section">Annex: Implementation</span></dt>
<dt><span class="section">Reference</span></dt>
<dd><dl>
<dt><span class="section">Header <boost/local_function.hpp></span></dt>
<dt><span class="section">Header <boost/local_function/config.hpp></span></dt>
</dl></dd>
-<dt><span class="section">Annex: Alternatives</span></dt>
-<dt><span class="section"><a href="boost_localfunction/No_Variadic_Macros.html">Annex: No Variadic
- Macros</a></span></dt>
-<dt><span class="section">Annex: Implementation</span></dt>
<dt><span class="section">Release Notes</span></dt>
<dt><span class="section">Bibliography</span></dt>
<dt><span class="section">Acknowledgments</span></dt>
@@ -129,12 +128,13 @@
</p>
<p>
Using <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> functions, it is possible to implement local functions by naming
- the lambdas assigning them to local variables. For example (see also add_lambda.cpp
):
+ lambda functions</a>, it is possible to implement local functions by naming
+ the lambda functions assigning them to local variables. For example (see also
+ add_cxx11_lambda.cpp
):
</p>
<p>
</p>
-<pre class="programlisting"><span class="special">{</span> <span class="comment">// Some local scope.</span>
+<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Some local scope.</span>
<span class="keyword">int</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span> <span class="comment">// Variables in scope to bind.</span>
<span class="keyword">auto</span> <span class="identifier">add</span> <span class="special">=</span> <span class="special">[</span><span class="identifier">factor</span><span class="special">,</span> <span class="special">&</span><span class="identifier">sum</span><span class="special">](</span><span class="keyword">int</span> <span class="identifier">num</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// C++11 only.</span>
@@ -145,7 +145,8 @@
<span class="keyword">int</span> <span class="identifier">nums</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span><span class="number">2</span><span class="special">,</span> <span class="number">3</span><span class="special">};</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">nums</span><span class="special">,</span> <span class="identifier">nums</span> <span class="special">+</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">add</span><span class="special">);</span> <span class="comment">// Pass it to an algorithm.</span>
- <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">sum</span> <span class="special">==</span> <span class="number">60</span><span class="special">);</span> <span class="comment">// Assert final summation value.</span>
+ <span class="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>
@@ -153,13 +154,12 @@
<p>
This library allows to program local functions portably between C++03
and C++11 (and
- with performances comparable to lambdas on C++11
- compilers, see the <a class="link" href="boost_localfunction/Alternatives.html" title="Annex: Alternatives">Alternatives</a>
- section). For example (see also add.cpp
):
+ with performances comparable to lambda functions on C++11
+ compilers). For example (see also add.cpp
):
</p>
<p>
</p>
-<pre class="programlisting"><span class="special">{</span> <span class="comment">// Some local scope.</span>
+<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Some local scope.</span>
<span class="keyword">int</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span> <span class="comment">// Variables in scope to bind.</span>
<span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">bind</span> <span class="identifier">factor</span><span class="special">,</span> <span class="identifier">bind</span><span class="special">&</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>
@@ -170,7 +170,8 @@
<span class="keyword">int</span> <span class="identifier">nums</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span><span class="number">2</span><span class="special">,</span> <span class="number">3</span><span class="special">};</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">nums</span><span class="special">,</span> <span class="identifier">nums</span> <span class="special">+</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">add</span><span class="special">);</span> <span class="comment">// Pass it to an algorithm.</span>
- <span class="identifier">BOOST_CHECK</span><span class="special">(</span><span class="identifier">sum</span> <span class="special">==</span> <span class="number">60</span><span class="special">);</span> <span class="comment">// Assert final summation value.</span>
+ <span class="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>
@@ -202,7 +203,7 @@
<p>
See the <a class="link" href="boost_localfunction/Alternatives.html" title="Annex: Alternatives">Alternatives</a>
section for a comparison between this library, <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> functions, Boost.Phoenix,
+ lambda functions</a>, Boost.Phoenix,
and other C++ techniques that implement features related to local functions.
</p>
</div>
@@ -217,14 +218,14 @@
</p></div>
<div class="footnote"><p><sup>[<a id="ftn.boost_localfunction.Introduction.f1" href="#boost_localfunction.Introduction.f1" class="para">2</a>] </sup>
This is a weakness with respect to <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions" target="_top">C++11
- lambda</a> functions which can instead be specified also within expressions
+ lambda functions</a> which can instead be specified also within expressions
(see the <a class="link" href="boost_localfunction/Alternatives.html" title="Annex: Alternatives">Alternatives</a>
section).
</p></div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"><p><small>Last revised: March 22, 2012 at 20:50:10 GMT</small></p></td>
+<td align="left"><p><small>Last revised: April 10, 2012 at 22:33:23 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-11 01:47:37 EDT (Wed, 11 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="index.html" title="Chapter 1. Boost.LocalFunction 1.0.0">
-<link rel="prev" href="boost_localfunction/Examples.html" title="Examples">
+<link rel="prev" href="boost_localfunction/Implementation.html" title="Annex: Implementation">
<link rel="next" href="BOOST_LOCAL_FUNCTION.html" title="Macro BOOST_LOCAL_FUNCTION">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
@@ -20,7 +20,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
-<a accesskey="p" href="boost_localfunction/Examples.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+<a accesskey="p" href="boost_localfunction/Implementation.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section reference">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
@@ -39,6 +39,7 @@
<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_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">
@@ -48,7 +49,8 @@
<pre class="synopsis">
<a class="link" href="BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX">BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX</a>
-<a class="link" href="BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX">BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX</a></pre>
+<a class="link" href="BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX">BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX</a>
+<a class="link" href="BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS.html" title="Macro BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS">BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS</a></pre>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
@@ -62,7 +64,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
-<a accesskey="p" href="boost_localfunction/Examples.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+<a accesskey="p" href="boost_localfunction/Implementation.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
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-11 01:47:37 EDT (Wed, 11 Apr 2012)
@@ -9,14 +9,14 @@
/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 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 __CPP03__ (see also __N2511__).
+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 __CPP11_lambda__ functions, it is possible to implement local functions by naming the lambdas assigning them to local variables.
-For example (see also [@../../test/add_lambda.cpp =add_lambda.cpp=]):
+Using __CXX11_lambda_functions__, it is possible to implement local functions by naming the lambda functions assigning them to local variables.
+For example (see also [@../../example/add_cxx11_lambda.cpp =add_cxx11_lambda.cpp=]):
-[add_lambda]
+[add_cxx11_lambda]
-This library allows to program local functions portably between __CPP03__ and __CPP11__ (and with performances comparable to lambdas on __CPP11__ compilers, see the __Alternatives__ section).
+This library allows to program local functions portably between __CXX03__ and __CXX11__ (and with performances comparable to lambda functions on __CXX11__ compilers).
For example (see also [@../../test/add.cpp =add.cpp=]):
[add]
@@ -27,14 +27,14 @@
* 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.
[footnote
-This is a strength with respect to __CPP03__ functors implemented using local classes which cannot be passed as template parameters (see __N2657__ and the __Alternatives__ section).
+This is a strength with respect to __CXX03__ functors implemented using local classes which cannot be passed as template parameters (see __N2657__ and the __Alternatives__ section).
]
* However, local functions must be specified within a declarative context (e.g., at a point in the code where local variables can be declared) thus they cannot be specified within expressions.
[footnote
-This is a weakness with respect to __CPP11_lambda__ functions which can instead be specified also within expressions (see the __Alternatives__ section).
+This is a weakness with respect to __CXX11_lambda_functions__ which can instead be specified also within expressions (see the __Alternatives__ section).
]
-See the __Alternatives__ section for a comparison between this library, __CPP11_lambda__ functions, __Boost_Phoenix__, and other C++ techniques that implement features related to local functions.
+See the __Alternatives__ section for a comparison between this library, __CXX11_lambda_functions__, __Boost_Phoenix__, and other C++ techniques that implement features related to local functions.
[endsect]
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-11 01:47:37 EDT (Wed, 11 Apr 2012)
@@ -19,8 +19,8 @@
[category Function Objects and Higher-Order Programming]
]
-[def __CPP03__ [@http://www.open-std.org/JTC1/SC22/WG21/docs/standards C++03]]
-[def __CPP11__ [@http://www.open-std.org/JTC1/SC22/WG21/ C++11]]
+[def __CXX03__ [@http://www.open-std.org/JTC1/SC22/WG21/docs/standards C++03]]
+[def __CXX11__ [@http://www.open-std.org/JTC1/SC22/WG21/ C++11]]
[def __C99__ [@http://www.open-std.org/jtc1/sc22/wg14/www/projects#9899 C99]]
[def __Boost__ [@http://www.boost.org Boost]]
[def __Boost_LocalFunction__ [@http://www.boost.org/libs/local_function Boost.LocalFunction]]
@@ -38,7 +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 __CPP11_lambda__ [@http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions C++11 lambda]]
+[def __CXX11_lambda_functions__ [@http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions C++11 lambda functions]]
[def __LISP__ [@http://en.wikipedia.org/wiki/Lisp_(programming_language) LISP]]
[def __Contractpp__ [@http://sourceforge.net/projects/contractpp Contract++]]
[def __D_Programming_Language__ [@http://d.digitalmars.com D Programming Language]]
@@ -64,7 +64,6 @@
[import ../test/add.cpp]
[import ../test/add_seq.cpp]
-[import ../test/add_lambda.cpp]
[import ../test/add_params_only.cpp]
[import ../test/ten_void.cpp]
[import ../test/add_this.cpp]
@@ -87,16 +86,17 @@
[import ../test/goto_error.cpp]
[import ../test/same_line.cpp]
+[import ../example/add_cxx11_lambda.cpp]
[import ../example/gcc_lambda.cpp]
-[import ../example/gcc_lambda_cxx11.cpp]
+[import ../example/gcc_cxx11_lambda.cpp]
[import ../example/const_block_error.cpp]
[import ../example/scope_exit.cpp]
[import ../example/scope_exit.hpp]
[import ../example/phoenix_factorial_local.cpp]
[import ../example/phoenix_factorial.cpp]
-[import ../example/noncopyable_lambda_error.cpp]
+[import ../example/noncopyable_cxx11_lambda_error.cpp]
[import ../example/noncopyable_local_function.cpp]
-[import ../example/expensive_copy_lambda.cpp]
+[import ../example/expensive_copy_cxx11_lambda.cpp]
[import ../example/expensive_copy_local_function.cpp]
[import ../example/add_local_functor.cpp]
[import ../example/add_global_functor.cpp]
@@ -111,10 +111,10 @@
[include tutorial.qbk]
[include advanced_topics.qbk]
[include examples.qbk]
-[xinclude reference.xml]
[include alternatives.qbk]
[include no_variadic_macros.qbk]
[include implementation.qbk]
+[xinclude reference.xml]
[include release_notes.qbk]
[include bibliography.qbk]
[include acknowledgements.qbk]
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-11 01:47:37 EDT (Wed, 11 Apr 2012)
@@ -11,25 +11,20 @@
#else
#include <boost/local_function.hpp>
-#include <boost/typeof/typeof.hpp>
-#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
#include <boost/detail/lightweight_test.hpp>
#include <vector>
#include <algorithm>
//[add_typed
-struct adder;
-BOOST_TYPEOF_REGISTER_TYPE(adder) // Unfortunately needed for `..._NAME` below.
-
-struct adder {
- adder() : sum_(0) {}
+struct adder { // No type-of used (or registration needed) because...
+ adder(void) : sum_(0) {}
int sum(const std::vector<int>& nums, const int& factor = 10) {
- // Explicitly specify bound variable and result types...
+ // ...explicitly specify bound variable types, return type, and ...
BOOST_LOCAL_FUNCTION(const bind(const int&) factor,
- bind(adder*) this_, int num, return int) {
- return this_->sum_ += factor * num;
- } BOOST_LOCAL_FUNCTION_NAME(add) // ... but this still uses type-of.
+ bind(adder*) this_, int num, return void) {
+ this_->sum_ += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME((void (int)) add) // ...function type.
std::for_each(nums.begin(), nums.end(), add);
return sum_;
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-11 01:47:37 EDT (Wed, 11 Apr 2012)
@@ -6,23 +6,18 @@
// Home at http://www.boost.org/libs/local_function
#include <boost/local_function.hpp>
-#include <boost/typeof/typeof.hpp>
-#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
#include <boost/detail/lightweight_test.hpp>
#include <vector>
#include <algorithm>
-struct adder;
-BOOST_TYPEOF_REGISTER_TYPE(adder) // Needed for `NAME` below.
-
struct adder {
- adder() : sum_(0) {}
+ adder(void) : sum_(0) {}
int sum(const std::vector<int>& nums, const int& factor = 10) {
BOOST_LOCAL_FUNCTION( (const bind(const int&) factor)
- (bind(adder*) this_) (int num) (return int) ) {
- return this_->sum_ += factor * num;
- } BOOST_LOCAL_FUNCTION_NAME(add)
+ (bind(adder*) this_) (int num) (return void) ) {
+ this_->sum_ += factor * num;
+ } BOOST_LOCAL_FUNCTION_NAME((void (int)) add)
std::for_each(nums.begin(), nums.end(), add);
return sum_;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk