|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r71673 - in sandbox/local: boost/local boost/local/aux_/function_macros libs/local/doc/html libs/local/doc/html/boost/local libs/local/doc/html/boost_local libs/local/doc/qbk libs/local/example
From: lorcaminiti_at_[hidden]
Date: 2011-05-02 11:57:52
Author: lcaminiti
Date: 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
New Revision: 71673
URL: http://svn.boost.org/trac/boost/changeset/71673
Log:
Fixed inline and recursive docs.
Text files modified:
sandbox/local/boost/local/aux_/function_macros/name.hpp | 59 ++++++++---
sandbox/local/boost/local/function.hpp | 37 +++++-
sandbox/local/libs/local/doc/html/BOOST_IDENTITY_TYPE.html | 2
sandbox/local/libs/local/doc/html/BOOST_IDENTITY_VALUE.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_BLOCK.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_BLOCK_END.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_BLOCK_TPL.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_CONFIG_COMPLIANT.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_CONFIG_FUNCTION_ARITY_MAX.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_CONFIG_THIS_PARAM_NAME.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT_END.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT_TPL.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_FUNCTION_NAME.html | 8 +
sandbox/local/libs/local/doc/html/BOOST_LOCAL_FUNCTION_PARAMS.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_FUNCTION_PARAMS_TPL.html | 2
sandbox/local/libs/local/doc/html/BOOST_LOCAL_TYPEOF.html | 2
sandbox/local/libs/local/doc/html/boost/local/function.html | 2
sandbox/local/libs/local/doc/html/boost_local/Advanced_Topics.html | 201 +++++++++++++++++++++++++++++++++++++--
sandbox/local/libs/local/doc/html/boost_local/Release_Notes.html | 59 -----------
sandbox/local/libs/local/doc/html/boost_local/Tutorial.html | 27 +++--
sandbox/local/libs/local/doc/html/index.html | 2
sandbox/local/libs/local/doc/qbk/advanced_topics.qbk | 43 ++++++++
sandbox/local/libs/local/doc/qbk/local.qbk | 3
sandbox/local/libs/local/doc/qbk/release_notes.qbk | 34 ------
sandbox/local/libs/local/doc/qbk/tutorial.qbk | 1
sandbox/local/libs/local/example/add_function_inline.cpp | 12 +-
sandbox/local/libs/local/example/add_function_inline_va.cpp | 12 +-
28 files changed, 360 insertions(+), 168 deletions(-)
Modified: sandbox/local/boost/local/aux_/function_macros/name.hpp
==============================================================================
--- sandbox/local/boost/local/aux_/function_macros/name.hpp (original)
+++ sandbox/local/boost/local/aux_/function_macros/name.hpp 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -16,6 +16,7 @@
#include <boost/preprocessor/control/iif.hpp>
#include <boost/preprocessor/control/expr_iif.hpp>
#include <boost/preprocessor/logical/bitor.hpp>
+#include <boost/preprocessor/tuple/eat.hpp>
// PRIVATE //
@@ -57,7 +58,7 @@
local_function_name = functor; \
} \
) \
- /* local functor can be passed as tparam only on C++03 (faster) */ \
+ /* local functor can be passed as tparam only on C++0x (faster) */ \
} local_functor_name(BOOST_LOCAL_AUX_SYMBOL_ARGS_VARIABLE_NAME.value); \
/* non-local functor can always be passed as tparam (but slower) */ \
BOOST_TYPEOF(local_functor_name. \
@@ -87,19 +88,19 @@
BOOST_LOCAL_AUX_FUNCTION_NAME_END_LOCAL_FUNCTOR_(__LINE__, \
local_function_name, \
/* local function is not recursive (because recursion and its */ \
- /* initialization cannot be inlined even on C++03, */ \
- /* so this allows optimization at least on C++03) */ \
+ /* initialization cannot be inlined even on C++0x, */ \
+ /* so this allows optimization at least on C++0x) */ \
0 /* not recursive */ , \
/* local functor */ \
BOOST_LOCAL_AUX_FUNCTION_NAME_FUNCTOR_(local_function_name), \
/* local function declared as non-local functor -- but it can */ \
- /* be inlined only by C++03 and it cannot be recursive */ \
+ /* be inlined only by C++0x 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++03 compilers.
-// Passed at tparam: Only on C++03. Inlineable: Yes. Recursive: No.
+// passed as a template parameter on non C++0x compilers.
+// Passed at tparam: Only on C++0x. Inlineable: Yes. Recursive: No.
#define BOOST_LOCAL_AUX_FUNCTION_NAME_INLINE_(local_function_name) \
BOOST_LOCAL_AUX_FUNCTION_NAME_END_LOCAL_FUNCTOR_(__LINE__, \
local_function_name, \
@@ -107,13 +108,13 @@
/* and its initialization cannot be inlined)*/ \
0 /* not recursive */ , \
/* inlined local function declared as local functor (maybe */ \
- /* inlined even by non C++03 -- but it can be passed as */ \
- /* template parameter only on C++03 */ \
+ /* inlined even by non C++0x -- but it can be passed as */ \
+ /* template parameter only on C++0x */ \
local_function_name, \
/* non-local functor */ \
BOOST_LOCAL_AUX_FUNCTION_NAME_FUNCTOR_(local_function_name))
-// This is slower on all compilers (C++03 and non) because recursion and its
+// This is slower on all compilers (C++0x and non) because recursion and its
// initialization can never be inlined.
// Passed at tparam: Yes. Inlineable: No. Recursive: Yes.
#define BOOST_LOCAL_AUX_FUNCTION_NAME_RECURSIVE_(local_function_name) \
@@ -124,37 +125,59 @@
/* local functor */ \
BOOST_LOCAL_AUX_FUNCTION_NAME_FUNCTOR_(local_function_name), \
/* local function declared as non-local functor -- but it can */ \
- /* be inlined only by C++03 */ \
+ /* be inlined only by C++0x */ \
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++03 compilers can always inline
+// (for example by GCC but not by MSVC). C++0x compilers can always inline
// local functions even if they are not explicitly specified inline.
#define BOOST_LOCAL_AUX_FUNCTION_NAME_PARSE_INLINE_(qualified_name) \
BOOST_PP_IIF(BOOST_PP_BITOR( \
BOOST_LOCAL_AUX_CONFIG_LOCAL_TYPES_AS_TPARAMS_01, \
BOOST_DETAIL_PP_KEYWORD_IS_INLINE_FRONT(qualified_name)), \
- /* on C++03 always use inlining because compilers might optimize */ \
+ /* on C++0x always use inlining because compilers might optimize */ \
/* it to be faster and it can also be passed as tparam */ \
BOOST_LOCAL_AUX_FUNCTION_NAME_INLINE_ \
, \
- /* on non C++03 don't use liniling unless explicitly specified by */ \
+ /* on non C++0x don't use liniling unless explicitly specified by */ \
/* programmers `inline name` the inlined local function cannot be */ \
/* passed as tparam */ \
BOOST_LOCAL_AUX_FUNCTION_NAME_ \
)(BOOST_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_AUX_FUNCTION_NAME_IS_RECURSIVE_(qualified_name) \
+ BOOST_LOCAL_AUX_PP_KEYWORD_IS_RECURSIVE_FRONT( \
+ BOOST_DETAIL_PP_KEYWORD_INLINE_REMOVE_FRONT(qualified_name))
+
+// Revmoes `recursive`, `inline recursive`, and `recursive inline` from front.
+#define BOOST_LOCAL_AUX_FUNCTION_NAME_REMOVE_RECURSIVE_AND_INLINE_( \
+ qualified_name) \
+ BOOST_LOCAL_AUX_PP_KEYWORD_RECURSIVE_REMOVE_FRONT( \
+ BOOST_DETAIL_PP_KEYWORD_INLINE_REMOVE_FRONT( \
+ BOOST_LOCAL_AUX_PP_KEYWORD_RECURSIVE_REMOVE_FRONT( \
+ qualified_name \
+ )))
+
+#define BOOST_LOCAL_AUX_FUNCTION_NAME_RECURSIVE_REMOVE_(qualified_name) \
+ BOOST_PP_IIF(BOOST_LOCAL_AUX_FUNCTION_NAME_IS_RECURSIVE_(qualified_name), \
+ BOOST_LOCAL_AUX_FUNCTION_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++03 compilers).
+// They can never be inlined for faster run-time (not even by C++0x compilers).
#define BOOST_LOCAL_AUX_FUNCTION_NAME_PARSE_RECURSIVE_(qualified_name) \
- BOOST_PP_IIF(BOOST_LOCAL_AUX_PP_KEYWORD_IS_RECURSIVE_FRONT( \
- qualified_name), \
- /* recursion can never be inlined (not even on C++03) */ \
+ BOOST_PP_IIF(BOOST_LOCAL_AUX_FUNCTION_NAME_IS_RECURSIVE_(qualified_name), \
+ /* recursion can never be inlined (not even on C++0x) */ \
BOOST_LOCAL_AUX_FUNCTION_NAME_RECURSIVE_ \
, \
BOOST_LOCAL_AUX_FUNCTION_NAME_PARSE_INLINE_ \
- )(BOOST_LOCAL_AUX_PP_KEYWORD_RECURSIVE_REMOVE_FRONT(qualified_name))
+ )(BOOST_LOCAL_AUX_FUNCTION_NAME_RECURSIVE_REMOVE_(qualified_name))
// PUBLIC //
Modified: sandbox/local/boost/local/function.hpp
==============================================================================
--- sandbox/local/boost/local/function.hpp (original)
+++ sandbox/local/boost/local/function.hpp 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -158,20 +158,41 @@
* This macro must follow the local function body code block <c>{ ... }</c> as
* shown in the @RefMacro{BOOST_LOCAL_FUNCTION_PARAMS} documentation.
*
+ * The local function name can be prefixed by the "keyword" <c>inline</c> as in
+ * <c>BOOST_LOCAL_FUNCTION_NAME(inline <em>name</em>)</c> to increase the
+ * chances that the compiler will be able to inline the local function calls
+ * (thus reducing their run-time).
+ * However, inlined local functions cannot be passed as template parameters
+ * (on ISO C++ compliant compilers, see
+ * @RefMacro{BOOST_LOCAL_CONFIG_COMPLIANT}, but they can be passed as template
+ * parameters on C++0x compilers).
+ * Furthermore, inlined local functions cannot be assigned to
+ * @RefClass{boost::local::function}.
+ * On C++0x compilers, there is no need to declare a local function lined
+ * because this library will automatically use C++0x specific features to
+ * inline the local function while always allowing to pass it as a template
+ * parameter.
+ *
+ * The local function name can also be prefixed by the "keyword"
+ * <c>recursive</c> as in
+ * <c>BOOST_LOCAL_FUNCTION_NAME(recursive <em>name</em>)</c> to allow the
+ * local function to recursively call itself from its body (as usual in C++).
+ * However, compilers have not been observed to be able to inline recursive
+ * local function calls (not even when the recursive local function is also
+ * declared inlined).
+ *
* @Params
* @Param{name,
* The name of the local function.
- * The local function name can be prefixed by the keyword <c>inline</c> as in
- * <c>BOOST_LOCAL_FUNCTION_NAME(inline <em>name</em>)</c> to increases the
- * likelihood that the compiler will inline the local function (thus reducing
- * its run-time) but inlined local functions can be passed as template
- * parameters only on C++03 compilers (and not on ISO C++ standard compilers)
- * -- see the @RefSect2{Advanced_Topics\, Advanced Topics} section.
+ * The local function name can be prefixed by the "keyword" <c>inline</c> to
+ * declare the local function inlined or by the "keyword" <c>recursive</c> to
+ * declare the local function recursive (see the @RefSect2{Advanced_Topics\,
+ * Advanced Topics} section).
* The local function name cannot be the name of an operator
* <c>operator...</c> and it cannot be the same name of another local function
* declared within the same enclosing scope (i.e.\, it is not possible to
- * overload local function declarations) -- see the
- * @RefSect2{Advanced_Topics\, Advanced Topics} section.
+ * overload local function declarations\, see the @RefSect2{Advanced_Topics\,
+ * Advanced Topics} section).
* }
* @EndParams
*
Modified: sandbox/local/libs/local/doc/html/BOOST_IDENTITY_TYPE.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_IDENTITY_TYPE.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_IDENTITY_TYPE.html 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_IDENTITY_TYPE(parenthesized_type)</pre></div>
<div class="refsect1">
-<a name="id916016"></a><h2>Description</h2>
+<a name="id918181"></a><h2>Description</h2>
<p>This macro expands to an expression that can be passed as a single macro parameter even if it contains commas and that evaluates to the specified type at compile-time (see the <a class="link" href="boost_local/Advanced_Topics.html" title="Advanced Topics"> Advanced Topics</a> section).</p>
<p>For example <code class="computeroutput">BOOST_IDENTITY_TYPE((std::map<int, double>))</code> can be passed as a single macro parameter when instead <code class="computeroutput">std::map<int, double></code> cannot (because it contains a comma not wrapped by round parenthesis so it will be interpreted as two separate macro parameters by the preprocessor).</p>
<p><span class="bold"><strong>Parameters:</strong></span> </p>
Modified: sandbox/local/libs/local/doc/html/BOOST_IDENTITY_VALUE.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_IDENTITY_VALUE.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_IDENTITY_VALUE.html 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_IDENTITY_VALUE(parenthesized_value)</pre></div>
<div class="refsect1">
-<a name="id916158"></a><h2>Description</h2>
+<a name="id918322"></a><h2>Description</h2>
<p>This macro expands to an expression that can be passed as a single macro parameter even if it contains commas and that evaluates to the specified value at run-time (see the <a class="link" href="boost_local/Advanced_Topics.html" title="Advanced Topics"> Advanced Topics</a> section).</p>
<p>For example <code class="computeroutput">BOOST_IDENTITY_VALUE((key_sizeof<int, double>::value))</code> can be passed as a single macro parameter when instead <code class="computeroutput">key_sizeof<int, double>::value</code> cannot (because it contains a comma not wrapped by round parenthesis so it will be interpreted as two separate macro parameters by the preprocessor).</p>
<p><span class="bold"><strong>Parameters:</strong></span> </p>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_BLOCK.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_BLOCK.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_BLOCK.html 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_BLOCK(bindings)</pre></div>
<div class="refsect1">
-<a name="id910930"></a><h2>Description</h2>
+<a name="id913022"></a><h2>Description</h2>
<p>This macro must be used within a declarative context, it must be followed by the local block body code and then by the <code class="computeroutput"><a class="link" href="BOOST_LOCAL_BLOCK_END.html" title="Macro BOOST_LOCAL_BLOCK_END">BOOST_LOCAL_BLOCK_END</a></code> macro (see the Tutorial section): </p>
<pre class="programlisting"> <span class="special">{</span> <span class="comment">// Some declarative context.</span>
<span class="special">...</span>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_BLOCK_END.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_BLOCK_END.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_BLOCK_END.html 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_BLOCK_END</pre></div>
<div class="refsect1">
-<a name="id911668"></a><h2>Description</h2>
+<a name="id913760"></a><h2>Description</h2>
<p>This macro must follow the local block body code <code class="computeroutput">{ ... }</code> as shown in the <code class="computeroutput"><a class="link" href="BOOST_LOCAL_BLOCK.html" title="Macro BOOST_LOCAL_BLOCK">BOOST_LOCAL_BLOCK</a></code> documentation.</p>
<p><span class="bold"><strong>Note:</strong></span> This macro cannot be used multiple times on the same line because it internally uses the line number <code class="computeroutput">__LINE__</code> to generate unique identifiers.</p>
<p><span class="bold"><strong>See:</strong></span> <code class="computeroutput"><a class="link" href="BOOST_LOCAL_BLOCK.html" title="Macro BOOST_LOCAL_BLOCK">BOOST_LOCAL_BLOCK</a></code>, <a class="link" href="boost_local/Tutorial.html" title="Tutorial">Tutorial</a> section. </p>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_BLOCK_TPL.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_BLOCK_TPL.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_BLOCK_TPL.html 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_BLOCK_TPL(bindings)</pre></div>
<div class="refsect1">
-<a name="id911594"></a><h2>Description</h2>
+<a name="id913686"></a><h2>Description</h2>
<p><span class="bold"><strong>See:</strong></span> <code class="computeroutput"><a class="link" href="BOOST_LOCAL_BLOCK.html" title="Macro BOOST_LOCAL_BLOCK">BOOST_LOCAL_BLOCK</a></code>, <a class="link" href="boost_local/Tutorial.html" title="Tutorial">Tutorial</a> section. </p>
</div>
</div>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_CONFIG_COMPLIANT.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_CONFIG_COMPLIANT.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_CONFIG_COMPLIANT.html 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_CONFIG_COMPLIANT</pre></div>
<div class="refsect1">
-<a name="id911836"></a><h2>Description</h2>
+<a name="id913927"></a><h2>Description</h2>
<p>If programmers leave this configuration macro undefined, its default value is to be left not defined.</p>
<p>If this macro is defined, variadic macros and empty macro parameters are not used by this library. Using variadic macros and empty macro parameters allows this library to provide the <span class="emphasis"><em>variadic macro</em></span> and <span class="emphasis"><em>empty macro</em></span> syntaxes which some programmers might find more readable than the <span class="emphasis"><em>sequencing macro</em></span> syntax (see <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_PARAMS.html" title="Macro BOOST_LOCAL_FUNCTION_PARAMS">BOOST_LOCAL_FUNCTION_PARAMS</a></code>, <code class="computeroutput"><a class="link" href="BOOST_LOCAL_BLOCK.html" title="Macro BOOST_LOCAL_BLOCK">BOOST_LOCAL_BLOCK</a></code>, and <code class="computeroutput"><a class="link" href="BOOST_LOCAL_EXIT.html" title="Macro BOOST_LOCAL_EXIT">BOOST_LOCAL_EXIT</a></code>). If this configuration macro is defined then only the sequencing macro syntax is allowed (regardless of whether the compiler supports variadic and e
mpty macros or not).</p>
<p><span class="bold"><strong>Warning:</strong></span> The variadic and empty macro syntaxes are not supported by all C++ compilers so they should be used with care to avoid portability issues (and this configuration macro can be defined to disable them).</p>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_CONFIG_FUNCTION_ARITY_MAX.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_CONFIG_FUNCTION_ARITY_MAX.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_CONFIG_FUNCTION_ARITY_MAX.html 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_CONFIG_FUNCTION_ARITY_MAX</pre></div>
<div class="refsect1">
-<a name="id912015"></a><h2>Description</h2>
+<a name="id914106"></a><h2>Description</h2>
<p>If programmers leave this configuration macro undefined, its default value is <code class="computeroutput">5</code>.</p>
<p>This only refers to the number of local function parameters and not to the number of bound variables in scope (the limit on the number of bound variables is instead the maximum size allowed for a Boost.Preprocessor sequences).</p>
<p><span class="bold"><strong>Warning:</strong></span> Increasing this number will increase compilation time.</p>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_CONFIG_THIS_PARAM_NAME.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_CONFIG_THIS_PARAM_NAME.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_CONFIG_THIS_PARAM_NAME.html 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_CONFIG_THIS_PARAM_NAME</pre></div>
<div class="refsect1">
-<a name="id912110"></a><h2>Description</h2>
+<a name="id914201"></a><h2>Description</h2>
<p>If programmers leave this configuration macro undefined, the default symbol used is <code class="computeroutput">this_</code>.</p>
<p><span class="bold"><strong>Warning:</strong></span> Programmers should not define this macro unless it is absolutely necessary (e.g., to avoid name clashes with another library which cannot be changed). Changing the symbol <code class="computeroutput">this_</code> effectively changes the public API of this library.</p>
<p><span class="bold"><strong>See:</strong></span> <a class="link" href="boost_local/Getting_Started.html" title="Getting Started"> Getting Started</a> section. </p>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT.html 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_EXIT(binding_list)</pre></div>
<div class="refsect1">
-<a name="id912251"></a><h2>Description</h2>
+<a name="id914341"></a><h2>Description</h2>
<p>This macro must be used within a declarative context, it must be followed by the local exit body code and then by the <code class="computeroutput"><a class="link" href="BOOST_LOCAL_EXIT_END.html" title="Macro BOOST_LOCAL_EXIT_END">BOOST_LOCAL_EXIT_END</a></code> macro (see the <a class="link" href="boost_local/Tutorial.html" title="Tutorial">Tutorial</a> section): </p>
<pre class="programlisting"> <span class="special">{</span> <span class="comment">// Some declarative context.</span>
<span class="special">...</span>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT_END.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT_END.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT_END.html 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_EXIT_END</pre></div>
<div class="refsect1">
-<a name="id913001"></a><h2>Description</h2>
+<a name="id915092"></a><h2>Description</h2>
<p>This macro must follow the local exit body code <code class="computeroutput">{ ... }</code> as shown in the <code class="computeroutput"><a class="link" href="BOOST_LOCAL_EXIT.html" title="Macro BOOST_LOCAL_EXIT">BOOST_LOCAL_EXIT</a></code> documentation.</p>
<p><span class="bold"><strong>Note:</strong></span> This macro cannot be used multiple times on the same line because it internally uses the line number <code class="computeroutput">__LINE__</code> to generate unique identifiers.</p>
<p><span class="bold"><strong>See:</strong></span> <code class="computeroutput"><a class="link" href="BOOST_LOCAL_EXIT.html" title="Macro BOOST_LOCAL_EXIT">BOOST_LOCAL_EXIT</a></code>, <a class="link" href="boost_local/Tutorial.html" title="Tutorial">Tutorial</a> section. </p>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT_TPL.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT_TPL.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_EXIT_TPL.html 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_EXIT_TPL(binding_list)</pre></div>
<div class="refsect1">
-<a name="id912927"></a><h2>Description</h2>
+<a name="id915018"></a><h2>Description</h2>
<p><span class="bold"><strong>See:</strong></span> <code class="computeroutput"><a class="link" href="BOOST_LOCAL_EXIT.html" title="Macro BOOST_LOCAL_EXIT">BOOST_LOCAL_EXIT</a></code>, <a class="link" href="boost_local/Tutorial.html" title="Tutorial">Tutorial</a> section. </p>
</div>
</div>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_FUNCTION_NAME.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_FUNCTION_NAME.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_FUNCTION_NAME.html 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -33,8 +33,10 @@
</span>BOOST_LOCAL_FUNCTION_NAME(name)</pre></div>
<div class="refsect1">
-<a name="id915464"></a><h2>Description</h2>
+<a name="id917554"></a><h2>Description</h2>
<p>This macro must follow the local function body code block <code class="computeroutput">{ ... }</code> as shown in the <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_PARAMS.html" title="Macro BOOST_LOCAL_FUNCTION_PARAMS">BOOST_LOCAL_FUNCTION_PARAMS</a></code> documentation.</p>
+<p>The local function name can be prefixed by the "keyword" <code class="computeroutput">inline</code> as in <code class="computeroutput">BOOST_LOCAL_FUNCTION_NAME(inline <span class="emphasis"><em>name</em></span>)</code> to increase the chances that the compiler will be able to inline the local function calls (thus reducing their run-time). However, inlined local functions cannot be passed as template parameters (on ISO C++ compliant compilers, see <code class="computeroutput"><a class="link" href="BOOST_LOCAL_CONFIG_COMPLIANT.html" title="Macro BOOST_LOCAL_CONFIG_COMPLIANT">BOOST_LOCAL_CONFIG_COMPLIANT</a></code>, but they can be passed as template parameters on C++0x compilers). Furthermore, inlined local functions cannot be assigned to <code class="computeroutput"><a class="link" href="boost/local/function.html" title="Struct template function">boost::local::function</a></code>. On C++0x compilers, there is no need to declare a local function lined because this library will automatically use C++0x sp
ecific features to inline the local function while always allowing to pass it as a template parameter.</p>
+<p>The local function name can also be prefixed by the "keyword" <code class="computeroutput">recursive</code> as in <code class="computeroutput">BOOST_LOCAL_FUNCTION_NAME(recursive <span class="emphasis"><em>name</em></span>)</code> to allow the local function to recursively call itself from its body (as usual in C++). However, compilers have not been observed to be able to inline recursive local function calls (not even when the recursive local function is also declared inlined).</p>
<p><span class="bold"><strong>Parameters:</strong></span> </p>
<div class="informaltable"><table class="table">
<colgroup>
@@ -43,7 +45,9 @@
</colgroup>
<tbody><tr>
<td><span class="bold"><strong><code class="computeroutput">name</code></strong></span></td>
-<td>The name of the local function. The local function name can be prefixed by the keyword <code class="computeroutput">inline</code> as in <code class="computeroutput">BOOST_LOCAL_FUNCTION_NAME(inline <span class="emphasis"><em>name</em></span>)</code> to increases the likelihood that the compiler will inline the local function (thus reducing its run-time) but inlined local functions can be passed as template parameters only on C++03 compilers (and not on ISO C++ standard compilers) -- see the <a class="link" href="boost_local/Advanced_Topics.html" title="Advanced Topics"> Advanced Topics</a> section. The local function name cannot be the name of an operator <code class="computeroutput">operator...</code> and it cannot be the same name of another local function declared within the same enclosing scope (i.e., it is not possible to overload local function declarations) -- see the <a class="link" href="boost_local/Advanced_Topics.html" title="Advanced Topics"> Advanced Topics</a> section. </td>
+<td>The name of the local function. The local function name can be prefixed by the "keyword" <code class="computeroutput">inline</code> to declare the local function inlined or by the "keyword" <code class="computeroutput">recursive</code> to declare the local function recursive (see the <a class="link" href="boost_local/Advanced_Topics.html" title="Advanced Topics">
+ Advanced Topics</a> section). The local function name cannot be the name of an operator <code class="computeroutput">operator...</code> and it cannot be the same name of another local function declared within the same enclosing scope (i.e., it is not possible to overload local function declarations, see the <a class="link" href="boost_local/Advanced_Topics.html" title="Advanced Topics">
+ Advanced Topics</a> section). </td>
</tr></tbody>
</table></div>
<p>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_FUNCTION_PARAMS.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_FUNCTION_PARAMS.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_FUNCTION_PARAMS.html 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_FUNCTION_PARAMS(parameters)</pre></div>
<div class="refsect1">
-<a name="id914490"></a><h2>Description</h2>
+<a name="id916580"></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_local/Tutorial.html" title="Tutorial">Tutorial</a> and <a class="link" href="boost_local/Advanced_Topics.html" title="Advanced Topics"> Advanced Topics</a> sections): </p>
<pre class="programlisting"> <span class="special">{</span> <span class="comment">// Some declarative context.</span>
<span class="special">...</span>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_FUNCTION_PARAMS_TPL.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_FUNCTION_PARAMS_TPL.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_FUNCTION_PARAMS_TPL.html 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_FUNCTION_PARAMS_TPL(parameters)</pre></div>
<div class="refsect1">
-<a name="id915390"></a><h2>Description</h2>
+<a name="id917480"></a><h2>Description</h2>
<p><span class="bold"><strong>See:</strong></span> <code class="computeroutput"><a class="link" href="BOOST_LOCAL_FUNCTION_PARAMS.html" title="Macro BOOST_LOCAL_FUNCTION_PARAMS">BOOST_LOCAL_FUNCTION_PARAMS</a></code>, <a class="link" href="boost_local/Tutorial.html" title="Tutorial">Tutorial</a> section. </p>
</div>
</div>
Modified: sandbox/local/libs/local/doc/html/BOOST_LOCAL_TYPEOF.html
==============================================================================
--- sandbox/local/libs/local/doc/html/BOOST_LOCAL_TYPEOF.html (original)
+++ sandbox/local/libs/local/doc/html/BOOST_LOCAL_TYPEOF.html 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_TYPEOF(bound_variable_name)</pre></div>
<div class="refsect1">
-<a name="id915689"></a><h2>Description</h2>
+<a name="id917853"></a><h2>Description</h2>
<p>The type is fully qualified in that it contains the extra constant and reference qualifiers when they are specified for binding by constant and by reference. For example, if a variable named <code class="computeroutput">x</code> of type <code class="computeroutput">T</code> is: </p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>Bound by value using <code class="computeroutput">bind x</code> then <code class="computeroutput">BOOST_LOCAL_TYPEOF(x)</code> is <code class="computeroutput">T</code>. </p></li>
Modified: sandbox/local/libs/local/doc/html/boost/local/function.html
==============================================================================
--- sandbox/local/libs/local/doc/html/boost/local/function.html (original)
+++ sandbox/local/libs/local/doc/html/boost/local/function.html 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -35,7 +35,7 @@
<span class="keyword">struct</span> <a class="link" href="function.html" title="Struct template function">function</a> <span class="special">{</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
-<a name="id913362"></a><h2>Description</h2>
+<a name="id915453"></a><h2>Description</h2>
<p>This template defines several specializations to handle a generic number of function parameters some of which can have default values. The number of supported function parameters <code class="computeroutput">N</code> goes from <code class="computeroutput">0</code> (for a function with no parameter) to a maximum of <code class="computeroutput"><a class="link" href="../../BOOST_LOCAL_CONFIG_FUNCTION_ARITY_MAX.html" title="Macro BOOST_LOCAL_CONFIG_FUNCTION_ARITY_MAX">BOOST_LOCAL_CONFIG_FUNCTION_ARITY_MAX</a></code>.</p>
<p>Each template specialization defines call operators <code class="computeroutput">operator()(...)</code> with a different set of parameters to handle the number of default parameters specified by <code class="computeroutput">defaults</code> (see <a class="link" href="../../boost_local/Advanced_Topics.html" title="Advanced Topics">
Advanced Topics</a> section): </p>
Modified: sandbox/local/libs/local/doc/html/boost_local/Advanced_Topics.html
==============================================================================
--- sandbox/local/libs/local/doc/html/boost_local/Advanced_Topics.html (original)
+++ sandbox/local/libs/local/doc/html/boost_local/Advanced_Topics.html 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -37,6 +37,8 @@
Specifications</a></span></dt>
<dt><span class="section"><a href="Advanced_Topics.html#boost_local.Advanced_Topics.storage_classifiers___auto__and__register__">Storage
Classifiers (<code class="computeroutput"><span class="keyword">auto</span></code> and <code class="computeroutput"><span class="keyword">register</span></code>)</a></span></dt>
+<dt><span class="section"><a href="Advanced_Topics.html#boost_local.Advanced_Topics.inlined_local_functions">Inlined
+ Local Functions</a></span></dt>
<dt><span class="section"><a href="Advanced_Topics.html#boost_local.Advanced_Topics.recursive_local_functions">Recursive
Local Functions</a></span></dt>
<dt><span class="section"><a href="Advanced_Topics.html#boost_local.Advanced_Topics.nested_declarations">Nested
@@ -83,7 +85,7 @@
<p>
In addition, local function parameter types cannot start with non-alphanumeric
symbols (alphanumeric symbols are <code class="computeroutput"><span class="identifier">A</span><span class="special">-</span><span class="identifier">Z</span></code>, <code class="computeroutput"><span class="identifier">a</span><span class="special">-</span><span class="identifier">z</span></code>,
- and <code class="computeroutput"><span class="number">0</span><span class="special">-</span><span class="number">9</span></code>). <sup>[<a name="id881339" href="#ftn.id881339" class="footnote">14</a>]</sup> The library will generate (cryptic) preprocessor errors if a
+ and <code class="computeroutput"><span class="number">0</span><span class="special">-</span><span class="number">9</span></code>). <sup>[<a name="id881374" href="#ftn.id881374" class="footnote">14</a>]</sup> The library will generate (cryptic) preprocessor errors if a
parameter type starts with a non-alphanumeric symbol.
</p>
<p>
@@ -206,7 +208,7 @@
<li class="listitem">
Parenthesis to wrap the type expression (and therefore any commas <code class="computeroutput"><span class="special">,</span></code> that it contains) passed as parameter
to the <code class="computeroutput"><a class="link" href="../BOOST_IDENTITY_TYPE.html" title="Macro BOOST_IDENTITY_TYPE">BOOST_IDENTITY_TYPE</a></code>
- macro. <sup>[<a name="id882699" href="#ftn.id882699" class="footnote">15</a>]</sup>
+ macro. <sup>[<a name="id882734" href="#ftn.id882734" class="footnote">15</a>]</sup>
</li>
</ol></div>
<p>
@@ -407,7 +409,7 @@
</p></td></tr>
</table></div>
<p>
- Consider the following complete example: <sup>[<a name="id884004" href="#ftn.id884004" class="footnote">16</a>]</sup>
+ Consider the following complete example: <sup>[<a name="id884038" href="#ftn.id884038" class="footnote">16</a>]</sup>
</p>
<div class="informaltable"><table class="table">
<colgroup>
@@ -1386,12 +1388,171 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_local.Advanced_Topics.inlined_local_functions"></a><a class="link" href="Advanced_Topics.html#boost_local.Advanced_Topics.inlined_local_functions" title="Inlined Local Functions">Inlined
+ Local Functions</a>
+</h3></div></div></div>
+<p>
+ A local function can be declared inlined to increase the chances that the
+ compiler will be able to reduce the local function call run-time by inlining
+ code. A local function is declared inlined by prefixing the local function
+ name specified to <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code>
+ with the "keyword" <code class="computeroutput"><span class="keyword">inline</span></code>:
+ </p>
+<pre class="programlisting"><span class="special">...</span> <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_PARAMS.html" title="Macro BOOST_LOCAL_FUNCTION_PARAMS">BOOST_LOCAL_FUNCTION_PARAMS</a></code><span class="special">(</span> <span class="special">...</span> <span class="special">)</span> <span class="special">{</span>
+ <span class="special">...</span>
+<span class="special">}</span> <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code><span class="special">(</span><span class="keyword">inline</span> <span class="special">...)</span>
+</pre>
+<div class="important"><table border="0" summary="Important">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="../../../../../doc/src/images/important.png"></td>
+<th align="left">Important</th>
+</tr>
+<tr><td align="left" valign="top">
+<p>
+ On ISO C++ compliant compilers (see <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_CONFIG_COMPLIANT.html" title="Macro BOOST_LOCAL_CONFIG_COMPLIANT">BOOST_LOCAL_CONFIG_COMPLIANT</a></code>),
+ inlined local functions always have a run-time comparable to their equivalent
+ implementations that use local functor classes (see the <a class="link" href="Alternatives.html" title="Appendix: Alternatives">Alternatives</a>
+ section). However, inlined local functions have the limitation that they
+ cannot be assigned to <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">local</span><span class="special">::</span><a class="link" href="../boost/local/function.html" title="Struct template function">function</a></code>
+ and they cannot be passed as template parameters <sup>[<a name="id904758" href="#ftn.id904758" class="footnote">17</a>]</sup>.
+ </p>
+<p>
+ On C++0x compilers, <code class="computeroutput"><span class="keyword">inline</span></code>
+ has no effect because this library will automatically generate code that
+ uses C++0x specific features to inline the local function calls whenever
+ possible even if the local function is not declared inlined.
+ </p>
+</td></tr>
+</table></div>
+<p>
+ It is recommended to not declare a local function inlined unless it is strictly
+ necessary for optimizing pure ISO C++ compliant code (because in all other
+ cases this library will automatically take advantage of C++0x features to
+ optimize the local function calls while always allowing to pass the local
+ function as a template parameter).
+ </p>
+<p>
+ For example, the following local function is declared inlined (thus a for-loop
+ needs to be used for portability instead of passing the local function as
+ a template parameter to the <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span></code>
+ algorithm):
+ </p>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ Variadic Macro Syntax (C99 and later compilers)
+ </p>
+ </th>
+<th>
+ <p>
+ Sequencing Macro Syntax (all C++ compilers)
+ </p>
+ </th>
+</tr></thead>
+<tbody><tr>
+<td>
+ <p>
+
+</p>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">local</span><span class="special">/</span><span class="identifier">function</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>
+<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
+
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> <span class="special">{</span>
+ <span class="keyword">double</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">0.0</span><span class="special">;</span>
+ <span class="keyword">int</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span>
+
+ <span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS</span><span class="special">(</span><span class="keyword">double</span> <span class="identifier">num</span><span class="special">,</span> <span class="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="special">{</span>
+ <span class="identifier">sum</span> <span class="special">+=</span> <span class="identifier">factor</span> <span class="special">*</span> <span class="identifier">num</span><span class="special">;</span>
+ <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="keyword">inline</span> <span class="identifier">add</span><span class="special">)</span> <span class="comment">// inlined local function</span>
+
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="identifier">v</span><span class="special">(</span><span class="number">1000000</span><span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">fill</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="number">1.0</span><span class="special">);</span>
+
+ <span class="comment">// On some ISO C++ compilers (e.g., GCC 4.3) inlined local functions are</span>
+ <span class="comment">// more likely to be optimized for faster run-times. However, inlined local</span>
+ <span class="comment">// functions cannot be passed at template parameters (i.e., `std::for_each`</span>
+ <span class="comment">// cannot be used here).</span>
+ <span class="comment">// On C++0x compilers (e.g., MSVC 8.0 or GCC 4.5) linining has no effect</span>
+ <span class="comment">// because the local function can always be optimized even if not</span>
+ <span class="comment">// explicitly specified inline and inlined local functions can be always be</span>
+ <span class="comment">// passed as template parameters.</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="identifier">v</span><span class="special">.</span><span class="identifier">size</span><span class="special">();</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Can't use for_each (portably).</span>
+ <span class="identifier">add</span><span class="special">(</span><span class="identifier">v</span><span class="special">[</span><span class="identifier">i</span><span class="special">]);</span>
+ <span class="special">}</span>
+
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">sum</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+ <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+ </td>
+<td>
+ <p>
+
+</p>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">local</span><span class="special">/</span><span class="identifier">function</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>
+<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
+
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> <span class="special">{</span>
+ <span class="keyword">double</span> <span class="identifier">sum</span> <span class="special">=</span> <span class="number">0.0</span><span class="special">;</span>
+ <span class="keyword">int</span> <span class="identifier">factor</span> <span class="special">=</span> <span class="number">10</span><span class="special">;</span>
+
+ <span class="keyword">void</span> <span class="identifier">BOOST_LOCAL_FUNCTION_PARAMS</span><span class="special">(</span> <span class="special">(</span><span class="keyword">double</span> <span class="identifier">num</span><span class="special">)</span> <span class="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="special">{</span>
+ <span class="identifier">sum</span> <span class="special">+=</span> <span class="identifier">factor</span> <span class="special">*</span> <span class="identifier">num</span><span class="special">;</span>
+ <span class="special">}</span> <span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span><span class="special">(</span><span class="keyword">inline</span> <span class="identifier">add</span><span class="special">)</span> <span class="comment">// inlined local function</span>
+
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="identifier">v</span><span class="special">(</span><span class="number">1000000</span><span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">fill</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="number">1.0</span><span class="special">);</span>
+
+ <span class="comment">// On some ISO C++ compilers (e.g., GCC 4.3) inlined local functions are</span>
+ <span class="comment">// more likely to be optimized for faster run-times. However, inlined local</span>
+ <span class="comment">// functions cannot be passed at template parameters (i.e., `std::for_each`</span>
+ <span class="comment">// cannot be used here).</span>
+ <span class="comment">// On C++0x compilers (e.g., MSVC 8.0 and GCC 4.5) linining has no effect</span>
+ <span class="comment">// because the local function can always be optimized even if not</span>
+ <span class="comment">// explicitly specified inline and inlined local functions can be always be</span>
+ <span class="comment">// passed as template parameters.</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="identifier">v</span><span class="special">.</span><span class="identifier">size</span><span class="special">();</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Can't use for_each (portably).</span>
+ <span class="identifier">add</span><span class="special">(</span><span class="identifier">v</span><span class="special">[</span><span class="identifier">i</span><span class="special">]);</span>
+ <span class="special">}</span>
+
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">sum</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+ <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+ </td>
+</tr></tbody>
+</table></div>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
<a name="boost_local.Advanced_Topics.recursive_local_functions"></a><a class="link" href="Advanced_Topics.html#boost_local.Advanced_Topics.recursive_local_functions" title="Recursive Local Functions">Recursive
Local Functions</a>
</h3></div></div></div>
<p>
- A local function can recursively call itself as usual with C++ functions.
+ A local function can be declared recursive so it can recursively call itself
+ from its body (as usual with C++ functions). A local function is declared
+ recursive by prefixing the local function name specified to <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code>
+ with the "keyword" <code class="computeroutput"><span class="identifier">recursive</span></code>:
</p>
+<pre class="programlisting"><span class="special">...</span> <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_PARAMS.html" title="Macro BOOST_LOCAL_FUNCTION_PARAMS">BOOST_LOCAL_FUNCTION_PARAMS</a></code><span class="special">(</span> <span class="special">...</span> <span class="special">)</span> <span class="special">{</span>
+ <span class="special">...</span>
+<span class="special">}</span> <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code><span class="special">(</span><span class="identifier">recursive</span> <span class="special">...)</span>
+</pre>
<p>
For example, the following local function is used to recursively calculate
and print the factorial of the specified numbers:
@@ -1506,6 +1667,10 @@
</td>
</tr></tbody>
</table></div>
+<p>
+ Compilers have not been observed to be able to inline recursive local function
+ calls (not even when the recursive local function is also declared inlined).
+ </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
@@ -1899,7 +2064,7 @@
It is not possible to overload local functions. Declaring multiple local
functions with the same name within the same enclosing scope generates a
compile-time error (even if the different declarations specify different
- parameters). <sup>[<a name="id909810" href="#ftn.id909810" class="footnote">17</a>]</sup>
+ parameters). <sup>[<a name="id911902" href="#ftn.id911902" class="footnote">18</a>]</sup>
</p>
<p>
For example, the following code will <span class="bold"><strong>not</strong></span>
@@ -1923,7 +2088,7 @@
</h6>
<p>
Local functions cannot be operators. Naming a local function <code class="computeroutput"><span class="keyword">operator</span><span class="special">...</span></code>
- will generate a compile-time error. <sup>[<a name="id910158" href="#ftn.id910158" class="footnote">18</a>]</sup>
+ will generate a compile-time error. <sup>[<a name="id912250" href="#ftn.id912250" class="footnote">19</a>]</sup>
</p>
<p>
For example, the following code will <span class="bold"><strong>not</strong></span>
@@ -1970,21 +2135,21 @@
</div>
<div class="footnotes">
<br><hr width="100" align="left">
-<div class="footnote"><p><sup>[<a id="ftn.id881339" href="#id881339" class="para">14</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id881374" href="#id881374" class="para">14</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> This limitation derives from
the fact that <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_PARAMS.html" title="Macro BOOST_LOCAL_FUNCTION_PARAMS">BOOST_LOCAL_FUNCTION_PARAMS</a></code>
uses preprocessor token concatenation to inspect the parameter type token
to see if the token is a parameter or a bound variable. The C++ preprocessor
does not allow to concatenate non-alphanumeric tokens.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id882699" href="#id882699" class="para">15</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id882734" href="#id882734" class="para">15</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> Using variadic macros,
this extra set of parenthesis could be eliminated requiring only the
parenthesis to invoke the <code class="computeroutput"><a class="link" href="../BOOST_IDENTITY_TYPE.html" title="Macro BOOST_IDENTITY_TYPE">BOOST_IDENTITY_TYPE</a></code>
macro. However, this feature is currently not implemented and the double
parenthesis are always needed when invoking this macro.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id884004" href="#id884004" class="para">16</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id884038" href="#id884038" class="para">16</a>] </sup>
The authors recognize that the use of the <span class="emphasis"><em>identity macros</em></span>
adds extra parenthesis to the already significant number of parenthesis
required by the sequencing macro syntax. However, macro parameters usually
@@ -1992,14 +2157,28 @@
(unless template metaprogramming is being used) so this is usually not
a problem.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id909810" href="#id909810" class="para">17</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id904758" href="#id904758" class="para">17</a>] </sup>
+ <span class="bold"><strong>Rationale.</strong></span> This library uses an indirect
+ function call via a function pointer in order to pass the local function
+ as a template parameter (see the <a class="link" href="Implementation.html" title="Appendix: Implementation">Implementation</a>
+ section). No compiler has been observed to be able to inline function
+ calls when they use such indirect function pointer calls. Therefore,
+ inlined local functions do not use such indirect function pointer call
+ (so they can be optimized) but because of that they cannot be passes
+ as template parameters. The indirect function pointer call is needed
+ for ISO C++ but it is not needed for C++0x (see [2657])
+ thus this library automatically generates local function calls that can
+ be inlined on C++0x compilers (even when the local function is not declared
+ inlined).
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.id911902" href="#id911902" class="para">18</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> This is because a local function
is a functor object declared as a local variable within the enclosing scope.
Therefore, declaring two local functions with the same name within the
same enclosing scope declares two local variables with the same name within
the same scope and that is not allowed in C++.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id910158" href="#id910158" class="para">18</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id912250" href="#id912250" class="para">19</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> This is the because a local
function name must be a valid local variable name (the local variable to
hold the local functor object) and operators cannot be used as local variable
Modified: sandbox/local/libs/local/doc/html/boost_local/Release_Notes.html
==============================================================================
--- sandbox/local/libs/local/doc/html/boost_local/Release_Notes.html (original)
+++ sandbox/local/libs/local/doc/html/boost_local/Release_Notes.html 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -70,52 +70,13 @@
</h3></div></div></div>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
- Add Inline Local Function <code class="computeroutput"><span class="special">...</span><span class="identifier">_NAME</span><span class="special">(</span><span class="keyword">inline</span> <span class="special"><</span><span class="identifier">name</span><span class="special">>)</span></code>
- to Advanced Topics section.
- </li>
-<li class="listitem">
- Add <code class="computeroutput"><span class="special">...</span><span class="identifier">_NAME</span><span class="special">(</span><span class="identifier">recursive</span>
- <span class="special"><</span><span class="identifier">name</span><span class="special">>)</span></code> to recursion section in Advanced
- Topics. Indicate that recursive local function cannot be optimized even
- when declared inline.
- </li>
-<li class="listitem">
- Modify <code class="computeroutput"><span class="special">...</span><span class="identifier">_NAME</span><span class="special">()</span></code> macro to parse also <code class="computeroutput"><span class="identifier">recursive</span>
- <span class="keyword">inline</span></code> and <code class="computeroutput"><span class="keyword">inline</span>
- <span class="identifier">recursive</span></code> as recursive (no
- reason to give an error, just ignore the inline request and document
- it).
- </li>
-<li class="listitem">
- Document recursive, inline, and that recursive is never inlined in <code class="computeroutput"><span class="special">...</span><span class="identifier">_NAME</span><span class="special">()</span></code> Doxygen.
- </li>
-<li class="listitem">
- Document limitation that inline local functions cannot be assigned to
- <code class="computeroutput"><span class="identifier">local</span><span class="special">::</span><span class="identifier">function</span></code> and therefore they cannot
- be passed as function parameters, etc.
+ Check if compilation times of Boost.Lambda and Boost.Phoenix change is
+ only specific headers are included (instead of the entire library header).
</li>
<li class="listitem">
Rework factorial_impl and Implementation section.
</li>
<li class="listitem">
- Read all N-papers about "passing local types as template parameters".
- </li>
-<li class="listitem">
- <span class="bold"><strong>Code.</strong></span> Optimize macro expansion code
- for C++0x, C++03, etc. From John Bytheway:
- </li>
-</ol></div>
-<pre class="programlisting"><span class="special">></span> <span class="identifier">Yes</span><span class="special">,</span> <span class="identifier">in</span> <span class="identifier">C</span><span class="special">++</span><span class="number">0</span><span class="identifier">x</span> <span class="identifier">local</span> <span class="identifier">structs</span> <span class="identifier">can</span> <span class="identifier">be</span> <span class="identifier">passed</span> <span class="identifier">as</span> <span class="keyword">template</span> <span class="identifier">parameters</span><span class="special">.</span>
-<span class="special">></span> <span class="identifier">Obviously</span><span class="special">,</span> <span class="identifier">in</span> <span class="identifier">C</span><span class="special">++</span><span class="number">0</span><span class="identifier">x</span> <span class="identifier">there</span> <span class="identifier">are</span> <span class="identifier">lambdas</span> <span class="identifier">too</span><span class="special">,</span> <span class="identifier">so</span> <span class="identifier">you</span> <span class="identifier">might</span> <span class="identifier">think</span> <span class="identifier">your</span>
-<span class="special">></span> <span class="identifier">library</span> <span class="identifier">is</span> <span class="identifier">useless</span><span class="special">,</span> <span class="identifier">but</span> <span class="identifier">I</span> <span class="identifier">would</span> <span class="identifier">expect</span> <span class="identifier">most</span> <span class="identifier">compilers</span> <span class="identifier">to</span> <span class="identifier">support</span> <span class="identifier">passing</span>
-<span class="special">></span> <span class="identifier">local</span> <span class="identifier">structs</span> <span class="identifier">as</span> <span class="keyword">template</span> <span class="identifier">parameters</span> <span class="identifier">before</span> <span class="identifier">they</span> <span class="identifier">support</span> <span class="identifier">lambdas</span><span class="special">,</span> <span class="identifier">so</span>
-<span class="special">></span> <span class="identifier">there</span> <span class="identifier">is</span> <span class="identifier">some</span> <span class="identifier">advantage</span> <span class="identifier">in</span> <span class="identifier">having</span> <span class="keyword">this</span> <span class="identifier">intermediate</span> <span class="identifier">implementation</span><span class="special">.</span>
-<span class="special">></span> <span class="identifier">Also</span><span class="special">,</span> <span class="identifier">your</span> <span class="identifier">macros</span> <span class="identifier">would</span> <span class="identifier">allow</span> <span class="identifier">writing</span> <span class="identifier">code</span> <span class="identifier">that</span> <span class="identifier">worked</span> <span class="identifier">in</span> <span class="identifier">C</span><span class="special">++</span><span class="number">0</span><span class="identifier">x</span> <span class="keyword">and</span>
-<span class="special">></span> <span class="identifier">C</span><span class="special">++</span><span class="number">03</span><span class="special">,</span> <span class="identifier">with</span> <span class="identifier">the</span> <span class="keyword">virtual</span> <span class="identifier">function</span> <span class="identifier">business</span> <span class="identifier">in</span> <span class="identifier">only</span> <span class="identifier">those</span> <span class="identifier">compilers</span><span class="special">/</span><span class="identifier">modes</span>
-<span class="special">></span> <span class="identifier">where</span> <span class="identifier">it</span> <span class="identifier">is</span> <span class="identifier">necessary</span><span class="special">.</span>
-</pre>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc">
-<li class="listitem">
Shall <code class="computeroutput"><span class="identifier">this_</span></code> be named
<code class="computeroutput"><span class="identifier">_this</span></code> instead? Ask Boosters
if there is some guideline for consistency. Maybe Boost uses <code class="computeroutput"><span class="special">...</span><span class="identifier">_</span></code>
@@ -124,21 +85,7 @@
for variables (like <code class="computeroutput"><span class="identifier">_1</span></code>)...
if that is the case then I should use <code class="computeroutput"><span class="identifier">_this</span></code>.
</li>
-<li class="listitem">
- Rename <code class="computeroutput"><span class="identifier">abstract_function</span></code>
- to <code class="computeroutput"><span class="identifier">function_interface</span></code>.
- </li>
-<li class="listitem">
- Provide a special macro <code class="computeroutput"><span class="identifier">BOOST_LOCAL_FUNCTION_NAME_OPTIMIZED</span></code>
- that runs faster (by using the local functor directly without using the
- global <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">local</span><span class="special">::</span><span class="identifier">function</span></code> functor instead). Make both
- local blocks and exits use this optimized local function variant. Document
- that this optimized local function variant cannot be passed as template
- parameter unless it is first manually reassigned to the global <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">local</span><span class="special">::</span><span class="identifier">function</span></code> functor or C++03 feature is
- supported by the compiler. On C++03, make <code class="computeroutput"><span class="identifier">BOOST_LOCAL_FUNCTION_NAME</span></code>
- be the same as <code class="computeroutput"><span class="identifier">BOOST_LOCAL_FUNCTION_NAME_OPTIMIZED</span></code>.
- </li>
-</ul></div>
+</ol></div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
Modified: sandbox/local/libs/local/doc/html/boost_local/Tutorial.html
==============================================================================
--- sandbox/local/libs/local/doc/html/boost_local/Tutorial.html (original)
+++ sandbox/local/libs/local/doc/html/boost_local/Tutorial.html 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -710,7 +710,7 @@
<p>
Unfortunately, mistakenly using <code class="computeroutput"><span class="keyword">this</span></code>
within the local function body instead of <code class="computeroutput"><span class="identifier">this_</span></code>
- will not necessarily generate a compile-time error. <sup>[<a name="id872134" href="#ftn.id872134" class="footnote">9</a>]</sup> Programmers are responsible to make sure that <code class="computeroutput"><span class="keyword">this</span></code> is never used within a local function
+ will not necessarily generate a compile-time error. <sup>[<a name="id872165" href="#ftn.id872165" class="footnote">9</a>]</sup> Programmers are responsible to make sure that <code class="computeroutput"><span class="keyword">this</span></code> is never used within a local function
body which should only use the special symbol <code class="computeroutput"><span class="identifier">this_</span></code>.
</p>
</td></tr>
@@ -892,7 +892,7 @@
<tr><td align="left" valign="top"><p>
A <code class="computeroutput"><span class="keyword">return</span><span class="special">;</span></code>
instruction from within a local block jumps to the end of the local block
- body and it does not return the enclosing function. <sup>[<a name="id875450" href="#ftn.id875450" class="footnote">10</a>]</sup>
+ body and it does not return the enclosing function. <sup>[<a name="id875485" href="#ftn.id875485" class="footnote">10</a>]</sup>
</p></td></tr>
</table></div>
<p>
@@ -1002,7 +1002,7 @@
</tr>
<tr><td align="left" valign="top"><p>
The execution of the local exit body code is guaranteed only if the program
- does not terminate because of an uncaught exception. <sup>[<a name="id876663" href="#ftn.id876663" class="footnote">11</a>]</sup>
+ does not terminate because of an uncaught exception. <sup>[<a name="id876698" href="#ftn.id876698" class="footnote">11</a>]</sup>
</p></td></tr>
</table></div>
<p>
@@ -1107,7 +1107,7 @@
Local exits are very similar to the <span class="emphasis"><em>scope exits</em></span> provided
by Boost.ScopeExit
with the addition that they also support constant binding and binding of
- the object <code class="computeroutput"><span class="keyword">this</span></code>. <sup>[<a name="id877918" href="#ftn.id877918" class="footnote">12</a>]</sup> Local exits can be used to emulate the <a href="http://d.digitalmars.com" target="_top">D
+ the object <code class="computeroutput"><span class="keyword">this</span></code>. <sup>[<a name="id877954" href="#ftn.id877954" class="footnote">12</a>]</sup> Local exits can be used to emulate the <a href="http://d.digitalmars.com" target="_top">D
Programming Language</a> <span class="emphasis"><em>scope guards</em></span> (see the
<a class="link" href="Examples.html#boost_local.Examples.Emulating_Ds_Scope_Guards" title="Emulating D's Scope Guards">Emulating
D's Scope Guards</a> example).
@@ -1121,7 +1121,7 @@
When local functions, local blocks, and local exits are programmed within
templates, they need to be declared using the following special macros ending
with the <code class="computeroutput"><span class="identifier">TPL</span></code> postfix (see
- the Reference section): <sup>[<a name="id878200" href="#ftn.id878200" class="footnote">13</a>]</sup>
+ the Reference section): <sup>[<a name="id878237" href="#ftn.id878237" class="footnote">13</a>]</sup>
</p>
<pre class="programlisting"><code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_PARAMS_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_PARAMS_TPL">BOOST_LOCAL_FUNCTION_PARAMS_TPL</a></code><span class="special">(</span><span class="emphasis"><em>parameters</em></span><span class="special">)</span>
<code class="computeroutput"><a class="link" href="../BOOST_LOCAL_BLOCK_TPL.html" title="Macro BOOST_LOCAL_BLOCK_TPL">BOOST_LOCAL_BLOCK_TPL</a></code><span class="special">(</span><span class="emphasis"><em>bindings</em></span><span class="special">)</span>
@@ -1326,9 +1326,14 @@
that the bound object must have a deep copy constructor) or by relying
on an <a href="http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/d3a86f27277f713b" target="_top">undefined
behaviour of <code class="computeroutput"><span class="keyword">static_cast</span></code></a>
- (which might not work on all platforms at the cost of portability).
+ (which might not work on all platforms at the cost of portability). Finally,
+ the special name <code class="computeroutput"><span class="identifier">this_</span></code>
+ was chose following <a href="http://boost.2283326.n4.nabble.com/local-this-or-this-td3423912.html" target="_top">Boost
+ practise</a> to postfix with an underscore identifier named after
+ keywords (the C++ keyword <code class="computeroutput"><span class="keyword">this</span></code>
+ in this case).
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id872134" href="#id872134" class="para">9</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id872165" href="#id872165" class="para">9</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> The local function body cannot
be a static member function of the local functor object in order to support
recursion (because the local function name is specified by the <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code>
@@ -1341,7 +1346,7 @@
is visible but it refers to the local functor object and not to the bound
object.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id875450" href="#id875450" class="para">10</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id875485" href="#id875485" class="para">10</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> Programmers might expect
<code class="computeroutput"><span class="keyword">return</span><span class="special">;</span></code>
to exit the enclosing function instead of the local block (or local exit),
@@ -1359,7 +1364,7 @@
<code class="computeroutput"><span class="identifier">BOOST_LOCAL_RETURN</span><span class="special">;</span></code>)
to exit local blocks (and local exits).
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id876663" href="#id876663" class="para">11</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id876698" href="#id876698" class="para">11</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> This library (as well as
<a href="http://www.boost.org/doc/libs/release/libs/scope_exit/doc/html/index.html" target="_top">Boost.ScopeExit</a>)
uses the destructor of a local variable to automatically execute the
@@ -1370,7 +1375,7 @@
scope exit code even if the main program terminates because of an uncaught
exception.)
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id877918" href="#id877918" class="para">12</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id877954" href="#id877954" class="para">12</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> This library could be merged
together with Boost.ScopeExit
into a new library named Boost.Scope (from the meaning of the word "scope"
@@ -1397,7 +1402,7 @@
of "<a href="http://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html" target="_top">nested
functions</a>" (GCC compiler extension).
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id878200" href="#id878200" class="para">13</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id878237" href="#id878237" class="para">13</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++ does not
Modified: sandbox/local/libs/local/doc/html/index.html
==============================================================================
--- sandbox/local/libs/local/doc/html/index.html (original)
+++ sandbox/local/libs/local/doc/html/index.html 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -416,7 +416,7 @@
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"><p><small>Last revised: May 01, 2011 at 23:05:54 GMT</small></p></td>
+<td align="left"><p><small>Last revised: May 02, 2011 at 15:54:49 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
Modified: sandbox/local/libs/local/doc/qbk/advanced_topics.qbk
==============================================================================
--- sandbox/local/libs/local/doc/qbk/advanced_topics.qbk (original)
+++ sandbox/local/libs/local/doc/qbk/advanced_topics.qbk 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -293,9 +293,48 @@
[endsect]
+[section Inlined Local Functions]
+
+A local function can be declared inlined to increase the chances that the compiler will be able to reduce the local function call run-time by inlining code.
+A local function is declared inlined by prefixing the local function name specified to `__BOOST_LOCAL_FUNCTION_NAME__` with the "keyword" `inline`:
+
+ ... __BOOST_LOCAL_FUNCTION_PARAMS__( ... ) {
+ ...
+ } __BOOST_LOCAL_FUNCTION_NAME__(inline ...)
+
+[important
+On ISO C++ compliant compilers (see __BOOST_LOCAL_CONFIG_COMPLIANT__), inlined local functions always have a run-time comparable to their equivalent implementations that use local functor classes (see the __Alternatives__ section).
+However, inlined local functions have the limitation that they cannot be assigned to `boost::local::__function__` and they cannot be passed as template parameters
+[footnote
+*Rationale.*
+This library uses an indirect function call via a function pointer in order to pass the local function as a template parameter (see the __Implementation__ section).
+No compiler has been observed to be able to inline function calls when they use such indirect function pointer calls.
+Therefore, inlined local functions do not use such indirect function pointer call (so they can be optimized) but because of that they cannot be passes as template parameters.
+The indirect function pointer call is needed for ISO C++ but it is not needed for C++0x (see __N2657__) thus this library automatically generates local function calls that can be inlined on C++0x compilers (even when the local function is not declared inlined).
+].
+
+On C++0x compilers, `inline` has no effect because this library will automatically generate code that uses C++0x specific features to inline the local function calls whenever possible even if the local function is not declared inlined.
+]
+
+It is recommended to not declare a local function inlined unless it is strictly necessary for optimizing pure ISO C++ compliant code (because in all other cases this library will automatically take advantage of C++0x features to optimize the local function calls while always allowing to pass the local function as a template parameter).
+
+For example, the following local function is declared inlined (thus a for-loop needs to be used for portability instead of passing the local function as a template parameter to the `std::for_each` algorithm):
+
+[table
+[ [__Variadic_Macro_Syntax__] [__Sequencing_Macro_Syntax__] ]
+[ [ [add_function_inline_va_cpp] ] [ [add_function_inline_cpp] ] ]
+]
+
+[endsect]
+
[section Recursive Local Functions]
-A local function can recursively call itself as usual with C++ functions.
+A local function can be declared recursive so it can recursively call itself from its body (as usual with C++ functions).
+A local function is declared recursive by prefixing the local function name specified to `__BOOST_LOCAL_FUNCTION_NAME__` with the "keyword" `recursive`:
+
+ ... __BOOST_LOCAL_FUNCTION_PARAMS__( ... ) {
+ ...
+ } __BOOST_LOCAL_FUNCTION_NAME__(recursive ...)
For example, the following local function is used to recursively calculate and print the factorial of the specified numbers:
@@ -304,6 +343,8 @@
[ [ [factorial_va_cpp] ] [ [factorial_cpp] ] ]
]
+Compilers have not been observed to be able to inline recursive local function calls (not even when the recursive local function is also declared inlined).
+
[endsect]
[section Nested Declarations]
Modified: sandbox/local/libs/local/doc/qbk/local.qbk
==============================================================================
--- sandbox/local/libs/local/doc/qbk/local.qbk (original)
+++ sandbox/local/libs/local/doc/qbk/local.qbk 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -68,6 +68,7 @@
[def __BOOST_LOCAL_EXIT_TPL__ [macroref BOOST_LOCAL_EXIT_TPL]]
[def __BOOST_LOCAL_EXIT_END__ [macroref BOOST_LOCAL_EXIT_END]]
[def __BOOST_LOCAL_TYPEOF__ [macroref BOOST_LOCAL_TYPEOF]]
+[def __BOOST_LOCAL_CONFIG_COMPLIANT__ [macroref BOOST_LOCAL_CONFIG_COMPLIANT]]
[def __BOOST_IDENTITY_TYPE__ [macroref BOOST_IDENTITY_TYPE]]
[def __BOOST_IDENTITY_VALUE__ [macroref BOOST_IDENTITY_VALUE]]
[def __function__ [classref boost::local::function function]]
@@ -111,6 +112,8 @@
[import ../../example/add_except_va.cpp]
[import ../../example/add_optimizers.cpp]
[import ../../example/add_optimizers_va.cpp]
+[import ../../example/add_function_inline.cpp]
+[import ../../example/add_function_inline_va.cpp]
[import ../../example/factorial.cpp]
[import ../../example/factorial_va.cpp]
[import ../../example/nesting.cpp]
Modified: sandbox/local/libs/local/doc/qbk/release_notes.qbk
==============================================================================
--- sandbox/local/libs/local/doc/qbk/release_notes.qbk (original)
+++ sandbox/local/libs/local/doc/qbk/release_notes.qbk 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -28,42 +28,10 @@
[section TODO]
-# Add Inline Local Function `..._NAME(inline <name>)` to Advanced Topics section.
-
-# Add `..._NAME(recursive <name>)` to recursion section in Advanced Topics.
-Indicate that recursive local function cannot be optimized even when declared inline.
-
-# Modify `..._NAME()` macro to parse also `recursive inline` and `inline recursive` as recursive (no reason to give an error, just ignore the inline request and document it).
-
-# Document recursive, inline, and that recursive is never inlined in `..._NAME()` Doxygen.
-
-# Document limitation that inline local functions cannot be assigned to `local::function` and therefore they cannot be passed as function parameters, etc.
+# Check if compilation times of Boost.Lambda and Boost.Phoenix change if only specific headers are included (instead of the entire library header).
# Rework factorial_impl and Implementation section.
-# Read all N-papers about "passing local types as template parameters".
-
-# *Code.* Optimize macro expansion code for C++0x, C++03, etc.
-From John Bytheway:
-
- > Yes, in C++0x local structs can be passed as template parameters.
- > Obviously, in C++0x there are lambdas too, so you might think your
- > library is useless, but I would expect most compilers to support passing
- > local structs as template parameters before they support lambdas, so
- > there is some advantage in having this intermediate implementation.
- > Also, your macros would allow writing code that worked in C++0x and
- > C++03, with the virtual function business in only those compilers/modes
- > where it is necessary.
-
-* Shall `this_` be named `_this` instead? Ask Boosters if there is some guideline for consistency. Maybe Boost uses `..._` is for statements (like `if_`) and `_...` for variables (like `_1`)... if that is the case then I should use `_this`.
-
-* Rename `abstract_function` to `function_interface`.
-
-* Provide a special macro `BOOST_LOCAL_FUNCTION_NAME_OPTIMIZED` that runs faster (by using the local functor directly without using the global `boost::local::function` functor instead).
-Make both local blocks and exits use this optimized local function variant.
-Document that this optimized local function variant cannot be passed as template parameter unless it is first manually reassigned to the global `boost::local::function` functor or C++03 feature is supported by the compiler.
-On C++03, make `BOOST_LOCAL_FUNCTION_NAME` be the same as `BOOST_LOCAL_FUNCTION_NAME_OPTIMIZED`.
-
[endsect]
[endsect]
Modified: sandbox/local/libs/local/doc/qbk/tutorial.qbk
==============================================================================
--- sandbox/local/libs/local/doc/qbk/tutorial.qbk (original)
+++ sandbox/local/libs/local/doc/qbk/tutorial.qbk 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -227,6 +227,7 @@
*Rationale.*
This limitation comes from the fact that `this` is a reserved C++ keyword so it cannot be used as the name of the internal parameter passing the bound object to the local function body.
It would be possible to use `this` (instead of `this_`) within the local function body either at the expenses of copying the bound object (which would introduce run-time overhead and also the stringent requirement that the bound object must have a deep copy constructor) or by relying on an [@http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/d3a86f27277f713b undefined behaviour of `static_cast`] (which might not work on all platforms at the cost of portability).
+Finally, the special name `this_` was chosen following [@http://boost.2283326.n4.nabble.com/local-this-or-this-td3423912.html Boost practise] to postfix with an underscore identifiers that are named after keywords (the C++ keyword `this` in this case).
]
Unfortunately, mistakenly using `this` within the local function body instead of `this_` will not necessarily generate a compile-time error.
Modified: sandbox/local/libs/local/example/add_function_inline.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_function_inline.cpp (original)
+++ sandbox/local/libs/local/example/add_function_inline.cpp 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -22,14 +22,14 @@
std::vector<double> v(1000000);
std::fill(v.begin(), v.end(), 1.0);
- // On some compiler (e.g., GCC) inlined local functions are more likely to
- // be optimized for faster run-times. However, inlined local functions
- // cannot be passed at template parameters (i.e., `std::for_each` cannot be
- // used here).
- // On C++03 compilers (e.g., MSVC or GCC 4.5) linining has no effect
+ // On some ISO C++ compilers (e.g., GCC 4.3) inlined local functions are
+ // more likely to be optimized for faster run-times. However, inlined local
+ // functions cannot be passed at template parameters (i.e., `std::for_each`
+ // cannot be used here).
+ // On C++0x compilers (e.g., MSVC 8.0 and GCC 4.5) linining has no effect
// because the local function can always be optimized even if not
// explicitly specified inline and inlined local functions can be always be
- // passed as template paramters.
+ // passed as template parameters.
for (size_t i = 0; i < v.size(); ++i) { // Can't use for_each (portably).
add(v[i]);
}
Modified: sandbox/local/libs/local/example/add_function_inline_va.cpp
==============================================================================
--- sandbox/local/libs/local/example/add_function_inline_va.cpp (original)
+++ sandbox/local/libs/local/example/add_function_inline_va.cpp 2011-05-02 11:57:48 EDT (Mon, 02 May 2011)
@@ -31,14 +31,14 @@
std::vector<double> v(1000000);
std::fill(v.begin(), v.end(), 1.0);
- // On some compiler (e.g., GCC) inlined local functions are more likely to
- // be optimized for faster run-times. However, inlined local functions
- // cannot be passed at template parameters (i.e., `std::for_each` cannot be
- // used here).
- // On C++03 compilers (e.g., MSVC or GCC 4.5) linining has no effect
+ // On some ISO C++ compilers (e.g., GCC 4.3) inlined local functions are
+ // more likely to be optimized for faster run-times. However, inlined local
+ // functions cannot be passed at template parameters (i.e., `std::for_each`
+ // cannot be used here).
+ // On C++0x compilers (e.g., MSVC 8.0 or GCC 4.5) linining has no effect
// because the local function can always be optimized even if not
// explicitly specified inline and inlined local functions can be always be
- // passed as template paramters.
+ // passed as template parameters.
for (size_t i = 0; i < v.size(); ++i) { // Can't use for_each (portably).
add(v[i]);
}
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