|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r71454 - in sandbox/local: boost/local 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-04-23 22:21:24
Author: lcaminiti
Date: 2011-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
New Revision: 71454
URL: http://svn.boost.org/trac/boost/changeset/71454
Log:
Added profiling.
Text files modified:
sandbox/local/boost/local/function.hpp | 3
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 | 6
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 | 8
sandbox/local/libs/local/doc/html/boost/local/function.html | 2
sandbox/local/libs/local/doc/html/boost_local/Advanced_Topics.html | 26 ++--
sandbox/local/libs/local/doc/html/boost_local/Alternatives.html | 241 ++++++++++++++++++++++++---------------
sandbox/local/libs/local/doc/html/boost_local/Getting_Started.html | 4
sandbox/local/libs/local/doc/html/boost_local/Implementation.html | 112 ++++++++++++++++++
sandbox/local/libs/local/doc/html/boost_local/Release_Notes.html | 20 ++
sandbox/local/libs/local/doc/html/boost_local/Tutorial.html | 50 ++++----
sandbox/local/libs/local/doc/html/index.html | 8
sandbox/local/libs/local/doc/html/reference.html | 3
sandbox/local/libs/local/doc/html/standalone_HTML.manifest | 1
sandbox/local/libs/local/doc/qbk/alternatives.qbk | 99 +++++++++++----
sandbox/local/libs/local/doc/qbk/implementation.qbk | 20 +++
sandbox/local/libs/local/doc/qbk/local.qbk | 3
sandbox/local/libs/local/example/Jamfile.jam | 10 +
sandbox/local/libs/local/example/benchmark_boost_lambda.cpp | 8
sandbox/local/libs/local/example/benchmark_boost_local.cpp | 27 +++-
sandbox/local/libs/local/example/benchmark_global_functor.cpp | 4
sandbox/local/libs/local/example/benchmark_local_functor.cpp | 18 +-
sandbox/local/libs/local/example/tparam_trick.10.cpp | 6
sandbox/local/libs/local/example/tparam_trick.cpp | 69 +++++++----
36 files changed, 524 insertions(+), 250 deletions(-)
Modified: sandbox/local/boost/local/function.hpp
==============================================================================
--- sandbox/local/boost/local/function.hpp (original)
+++ sandbox/local/boost/local/function.hpp 2011-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -174,6 +174,9 @@
#define BOOST_LOCAL_FUNCTION_NAME(name) \
BOOST_LOCAL_AUX_FUNCTION_NAME(name)
+#define BOOST_LOCAL_FUNCTION_NAME_OPTIMIZED(name) \
+ BOOST_LOCAL_AUX_FUNCTION_NAME_OPTIMIZED(name)
+
namespace boost { namespace local {
/**
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-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -33,7 +33,7 @@
</span>BOOST_IDENTITY_TYPE(parenthesized_type)</pre></div>
<div class="refsect1">
-<a name="id915945"></a><h2>Description</h2>
+<a name="id915985"></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-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -33,7 +33,7 @@
</span>BOOST_IDENTITY_VALUE(parenthesized_value)</pre></div>
<div class="refsect1">
-<a name="id916086"></a><h2>Description</h2>
+<a name="id916126"></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-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_BLOCK(bindings)</pre></div>
<div class="refsect1">
-<a name="id910882"></a><h2>Description</h2>
+<a name="id910870"></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-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_BLOCK_END</pre></div>
<div class="refsect1">
-<a name="id911627"></a><h2>Description</h2>
+<a name="id911616"></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-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_BLOCK_TPL(bindings)</pre></div>
<div class="refsect1">
-<a name="id911553"></a><h2>Description</h2>
+<a name="id911542"></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-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_CONFIG_COMPLIANT</pre></div>
<div class="refsect1">
-<a name="id911795"></a><h2>Description</h2>
+<a name="id911784"></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-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_CONFIG_FUNCTION_ARITY_MAX</pre></div>
<div class="refsect1">
-<a name="id911975"></a><h2>Description</h2>
+<a name="id911963"></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-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_CONFIG_THIS_PARAM_NAME</pre></div>
<div class="refsect1">
-<a name="id912070"></a><h2>Description</h2>
+<a name="id912059"></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-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_EXIT(binding_list)</pre></div>
<div class="refsect1">
-<a name="id912210"></a><h2>Description</h2>
+<a name="id912199"></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-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_EXIT_END</pre></div>
<div class="refsect1">
-<a name="id912961"></a><h2>Description</h2>
+<a name="id912949"></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-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_EXIT_TPL(binding_list)</pre></div>
<div class="refsect1">
-<a name="id912887"></a><h2>Description</h2>
+<a name="id912875"></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-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -7,7 +7,7 @@
<link rel="home" href="index.html" title="Boost.Local 0.2.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_PARAMS_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_PARAMS_TPL">
-<link rel="next" href="BOOST_LOCAL_TYPEOF.html" title="Macro BOOST_LOCAL_TYPEOF">
+<link rel="next" href="BOOST_LOCAL_FUNCTION_NAME_OPTIMIZED.html" title="Macro BOOST_LOCAL_FUNCTION_NAME_OPTIMIZED">
</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_PARAMS_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_TYPEOF.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_PARAMS_TPL.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local.function_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_NAME_OPTIMIZED.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>
@@ -61,7 +61,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
-<a accesskey="p" href="BOOST_LOCAL_FUNCTION_PARAMS_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_TYPEOF.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_PARAMS_TPL.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local.function_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_LOCAL_FUNCTION_NAME_OPTIMIZED.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
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-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_FUNCTION_PARAMS(parameters)</pre></div>
<div class="refsect1">
-<a name="id914450"></a><h2>Description</h2>
+<a name="id914449"></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-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_FUNCTION_PARAMS_TPL(parameters)</pre></div>
<div class="refsect1">
-<a name="id915350"></a><h2>Description</h2>
+<a name="id915349"></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-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -6,7 +6,7 @@
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="Boost.Local 0.2.0">
<link rel="up" href="reference.html#header.boost.local.typeof_hpp" title="Header <boost/local/typeof.hpp>">
-<link rel="prev" href="BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">
+<link rel="prev" href="BOOST_LOCAL_FUNCTION_NAME_OPTIMIZED.html" title="Macro BOOST_LOCAL_FUNCTION_NAME_OPTIMIZED">
<link rel="next" href="BOOST_IDENTITY_TYPE.html" title="Macro BOOST_IDENTITY_TYPE">
</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.typeof_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_IDENTITY_TYPE.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_NAME_OPTIMIZED.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local.typeof_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_IDENTITY_TYPE.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="BOOST_LOCAL_TYPEOF"></a><div class="titlepage"></div>
@@ -33,7 +33,7 @@
</span>BOOST_LOCAL_TYPEOF(bound_variable_name)</pre></div>
<div class="refsect1">
-<a name="id915618"></a><h2>Description</h2>
+<a name="id915658"></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>
@@ -70,7 +70,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.typeof_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_IDENTITY_TYPE.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+<a accesskey="p" href="BOOST_LOCAL_FUNCTION_NAME_OPTIMIZED.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.local.typeof_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_IDENTITY_TYPE.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
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-04-23 22:21:20 EDT (Sat, 23 Apr 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="id913322"></a><h2>Description</h2>
+<a name="id913321"></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-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -83,7 +83,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="id881358" href="#ftn.id881358" 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="id881348" href="#ftn.id881348" 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 +206,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="id882716" href="#ftn.id882716" class="footnote">15</a>]</sup>
+ macro. <sup>[<a name="id882705" href="#ftn.id882705" class="footnote">15</a>]</sup>
</li>
</ol></div>
<p>
@@ -407,7 +407,7 @@
</p></td></tr>
</table></div>
<p>
- Consider the following complete example: <sup>[<a name="id884020" href="#ftn.id884020" class="footnote">16</a>]</sup>
+ Consider the following complete example: <sup>[<a name="id884010" href="#ftn.id884010" class="footnote">16</a>]</sup>
</p>
<div class="informaltable"><table class="table">
<colgroup>
@@ -1892,14 +1892,14 @@
</tbody>
</table></div>
<a name="boost_local.Advanced_Topics.limitations__overloading__operators__etc_.overloading"></a><h6>
-<a name="id909749"></a>
+<a name="id909738"></a>
<a class="link" href="Advanced_Topics.html#boost_local.Advanced_Topics.limitations__overloading__operators__etc_.overloading">Overloading</a>
</h6>
<p>
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="id909773" href="#ftn.id909773" class="footnote">17</a>]</sup>
+ parameters). <sup>[<a name="id909763" href="#ftn.id909763" class="footnote">17</a>]</sup>
</p>
<p>
For example, the following code will <span class="bold"><strong>not</strong></span>
@@ -1918,12 +1918,12 @@
<span class="special">}</span>
</pre>
<a name="boost_local.Advanced_Topics.limitations__overloading__operators__etc_.operators"></a><h6>
-<a name="id910079"></a>
+<a name="id910069"></a>
<a class="link" href="Advanced_Topics.html#boost_local.Advanced_Topics.limitations__overloading__operators__etc_.operators">Operators</a>
</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="id910116" href="#ftn.id910116" class="footnote">18</a>]</sup>
+ will generate a compile-time error. <sup>[<a name="id910106" href="#ftn.id910106" class="footnote">18</a>]</sup>
</p>
<p>
For example, the following code will <span class="bold"><strong>not</strong></span>
@@ -1944,7 +1944,7 @@
<span class="special">}</span>
</pre>
<a name="boost_local.Advanced_Topics.limitations__overloading__operators__etc_.goto"></a><h6>
-<a name="id910491"></a>
+<a name="id910480"></a>
<a class="link" href="Advanced_Topics.html#boost_local.Advanced_Topics.limitations__overloading__operators__etc_.goto">Goto</a>
</h6>
<p>
@@ -1970,21 +1970,21 @@
</div>
<div class="footnotes">
<br><hr width="100" align="left">
-<div class="footnote"><p><sup>[<a id="ftn.id881358" href="#id881358" class="para">14</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id881348" href="#id881348" 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.id882716" href="#id882716" class="para">15</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id882705" href="#id882705" 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.id884020" href="#id884020" class="para">16</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id884010" href="#id884010" 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 +1992,14 @@
(unless template metaprogramming is being used) so this is usually not
a problem.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id909773" href="#id909773" class="para">17</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id909763" href="#id909763" class="para">17</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.id910116" href="#id910116" class="para">18</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id910106" href="#id910106" class="para">18</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/Alternatives.html
==============================================================================
--- sandbox/local/libs/local/doc/html/boost_local/Alternatives.html (original)
+++ sandbox/local/libs/local/doc/html/boost_local/Alternatives.html 2011-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -289,104 +289,12 @@
</p>
</td>
</tr>
-<tr>
-<td>
- <p>
- <span class="emphasis"><em>Compile-Time</em></span> <sup>[<a name="id944627" href="#ftn.id944627" class="footnote">a</a>]</sup>
- </p>
- </td>
-<td>
- <p>
- 0 seconds
- </p>
- </td>
-<td>
- <p>
- 0 seconds
- </p>
- </td>
-<td>
- <p>
- 0 seconds
- </p>
- </td>
-<td>
- <p>
- 0 seconds
- </p>
- </td>
-<td>
- <p>
- 0 seconds
- </p>
- </td>
-<td>
- <p>
- 0 seconds
- </p>
- </td>
-</tr>
-<tr>
-<td>
- <p>
- <span class="emphasis"><em>Run-Time</em></span> <sup>[<a name="id944729" href="#ftn.id944729" class="footnote">b</a>]</sup>
- </p>
- </td>
-<td>
- <p>
- 0 seconds
- </p>
- </td>
-<td>
- <p>
- 0 seconds
- </p>
- </td>
-<td>
- <p>
- 0 seconds
- </p>
- </td>
-<td>
- <p>
- 0 seconds
- </p>
- </td>
-<td>
- <p>
- 0 seconds
- </p>
- </td>
-<td>
- <p>
- 0 seconds
- </p>
- </td>
-</tr>
</tbody>
-<tbody class="footnotes"><tr><td colspan="7">
-<div class="footnote"><p><sup>[<a id="ftn.id944627" href="#id944627" class="para">a</a>] </sup>
- Compilation times have been measured in seconds using the Linux
- command <code class="literal">$ time g++ -O3 -Wall -Wextra -I<BOOST_DIR>
- <CPP_FILE></code> for the examples listed below for
- all the different approaches. The <code class="literal">real</code> time
- is the overall time that took to execute the command. The actual
- time values can change from execution to execution therefore
- they have been measured 3 times and the time reported it the
- one with the middle <code class="literal">real</code> time value. The time
- values are machine dependent so they have no absolute meaning
- but they can be used in this context to compare the performances
- of the different approaches relative to each other (because all
- these values were measured on the same system).
- </p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id944729" href="#id944729" class="para">b</a>] </sup>
- run times have been measured in seconds using the Linux command
- <code class="literal">$ time <COMPILED_PROGRAM></code> for the compiled
- examples listed below for all the different approaches. The same
- statistical approach as for compilation time was followed.
- </p></div>
-</td></tr></tbody>
</table></div>
+<a name="boost_local.Alternatives.local_functions.examples"></a><h6>
+<a name="id944670"></a>
+ <a class="link" href="Alternatives.html#boost_local.Alternatives.local_functions.examples">Examples</a>
+ </h6>
<p>
For example, using this library local functions:
</p>
@@ -670,6 +578,147 @@
</pre>
<p>
</p>
+<a name="boost_local.Alternatives.local_functions.profiling"></a><h6>
+<a name="id950582"></a>
+ <a class="link" href="Alternatives.html#boost_local.Alternatives.local_functions.profiling">Profiling</a>
+ </h6>
+<p>
+ The following table compares compile-time, binary size, and run-time among
+ the different alternatives.
+ </p>
+<p>
+ This library has compile-times and generates binary size similar to the ones
+ of the other approaches. This library run-times on ISO C++ compliant compilers
+ "Boost.Local
+ Compliant" were measured to be similar to "Local Functor"
+ but larger than other approaches like "Global Functor", "Boost.Lambda",
+ or "Boost.Phoenix"
+ when compiler optimization is enabled. However, on C++03 compilers (e.g.,
+ MSVC) this library generates optimized code "Boost.Local"
+ that runs as fast as the fastest of the other approaches. Finally, this library
+ run-times are always among the fastest when no compiler optimization is used.
+ </p>
+<div class="note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top">
+<p>
+ This is because on non C++03 compilers (e.g., GCC) this library needs to
+ use a function pointer in order to pass the local functor class as a template
+ parameter (see the <a class="link" href="Implementation.html" title="Appendix: Implementation">Implementation</a>
+ section). This function pointer prevents the compiler from inlining all
+ the function calls while the functors used by other approaches like "Boost.Lambda"
+ and "Boost.Phoenix"
+ allows the compiler to inline all the function calls.
+ </p>
+<p>
+ This performance hit on non C++03 compilers might or not be a problem depending
+ on the performance requirements of your application. For example, your
+ application might already be using a number of indirect function calls
+ (function pointers, virtual functions, etc) because of which the overload
+ added by using the one extra function pointer required by the local function
+ might not be noticeable within your overall program run-time.
+ </p>
+</td></tr>
+</table></div>
+<p>
+ Finally, note that a very simple local function body with only one instruction
+ was used for this profiling (see files profile_boost_local.cpp
,
+ profile_boost_local_for_loop.cpp
,
+ profile_boost_local_optimized.cpp
,
+ profile_local_functor.cpp
,
+ profile_global_functor.cpp
,
+ profile_0x_lambda.cpp
,
+ profile_boost_lambda.cpp
,
+ and profile_boost_phoenix.cpp
).
+ It has not been studied how this library and the other approaches will perform
+ with respect to each other when a more complex set of instructions is programmed
+ by the local function body.
+ </p>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ <code class="literal">bjam release</code> on MSVC 8.0 (maximum optimization
+ <code class="literal">/O2 /Ob2</code>)
+ </p>
+ </th>
+<th>
+ <p>
+ <code class="literal">bjam debug</code> on MSVC 8.0 (no optimization <code class="literal">/O0
+ /Ob0</code>)
+ </p>
+ </th>
+</tr></thead>
+<tbody>
+<tr>
+<td>
+ <p>
+ The local function was called <code class="literal">1e8</code> times to add
+ together all the elements of a vector. The run-time was measured
+ using Boost.Chrono
+ and averaged over <code class="literal">100</code> executions of the vector
+ summation (see the relative <code class="literal">profile_...</code> example
+ files).
+ </p>
+ </td>
+<td>
+ <p>
+ The local function was called <code class="literal">1e8</code> times to add
+ together all the elements of a vector. The run-time was measured
+ using Boost.Chrono
+ and averaged over <code class="literal">1</code> execution of the vector
+ summation (see the relative <code class="literal">profile_...</code> example
+ files).
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <span class="inlinemediaobject"><img src="../../../example/profile_msvc-8.0_release.png" width="630" alt="profile_msvc-8.0_release"></span>
+ </p>
+ </td>
+<td>
+ <p>
+ <span class="inlinemediaobject"><img src="../../../example/profile_msvc-8.0_debug.png" width="630" alt="profile_msvc-8.0_debug"></span>
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ Commands used to measure compile-time, binary size, and run-time
+ from the library example directory:
+</p>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="special">></span> <span class="identifier">python</span> <span class="identifier">chrono</span><span class="special">.</span><span class="identifier">py</span> <span class="identifier">bjam</span> <span class="identifier">release</span> <span class="special"><</span><span class="identifier">PROGRAM</span><span class="special">></span>
+<span class="special">></span> <span class="identifier">size</span> <span class="special"><</span><span class="identifier">PROGRAM</span><span class="special">></span> <span class="preprocessor"># Cygwin</span> <span class="identifier">command</span>
+<span class="special">></span> <span class="special"><</span><span class="identifier">PROGRAM</span><span class="special">></span> <span class="number">100000000</span> <span class="number">100</span>
+</pre>
+<p>
+ </p>
+ </td>
+<td>
+ <p>
+ Commands used to measure compile-time, binary size, and run-time
+ from the library example directory:
+</p>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="special">></span> <span class="identifier">python</span> <span class="identifier">chrono</span><span class="special">.</span><span class="identifier">py</span> <span class="identifier">bjam</span> <span class="identifier">debug</span> <span class="special"><</span><span class="identifier">PROGRAM</span><span class="special">></span>
+<span class="special">></span> <span class="identifier">size</span> <span class="special"><</span><span class="identifier">PROGRAM</span><span class="special">></span> <span class="preprocessor"># Cygwin</span> <span class="identifier">command</span>
+<span class="special">></span> <span class="special"><</span><span class="identifier">PROGRAM</span><span class="special">></span> <span class="number">100000000</span> <span class="number">1</span>
+</pre>
+<p>
+ </p>
+ </td>
+</tr>
+</tbody>
+</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
Modified: sandbox/local/libs/local/doc/html/boost_local/Getting_Started.html
==============================================================================
--- sandbox/local/libs/local/doc/html/boost_local/Getting_Started.html (original)
+++ sandbox/local/libs/local/doc/html/boost_local/Getting_Started.html 2011-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -121,7 +121,7 @@
</pre>
<p>
The following symbols are part of the library private API, they are not documented,
- and they should not be directly used by programmers: <sup>[<a name="id866137" href="#ftn.id866137" class="footnote">1</a>]</sup>
+ and they should not be directly used by programmers: <sup>[<a name="id866119" href="#ftn.id866119" class="footnote">1</a>]</sup>
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
@@ -159,7 +159,7 @@
</div>
<div class="footnotes">
<br><hr width="100" align="left">
-<div class="footnote"><p><sup>[<a id="ftn.id866137" href="#id866137" class="para">1</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id866119" href="#id866119" class="para">1</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> This library concatenates symbols
specified by the programmers (e.g., the local function name) with other
symbols (e.g., special prefixes or preprocessor line numbers) to make internal
Modified: sandbox/local/libs/local/doc/html/boost_local/Implementation.html
==============================================================================
--- sandbox/local/libs/local/doc/html/boost_local/Implementation.html (original)
+++ sandbox/local/libs/local/doc/html/boost_local/Implementation.html 2011-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -28,6 +28,8 @@
</h2></div></div></div>
<div class="toc"><dl>
<dt><span class="section">Local Functions</span></dt>
+<dt><span class="section"><a href="Implementation.html#boost_local.Implementation.local_classes_as_template_parameters">Local
+ Classes as Template Parameters</a></span></dt>
<dt><span class="section">Local Blocks</span></dt>
<dt><span class="section">Local Exits</span></dt>
<dt><span class="section">Parsing Macros</span></dt>
@@ -215,6 +217,116 @@
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_local.Implementation.local_classes_as_template_parameters"></a><a class="link" href="Implementation.html#boost_local.Implementation.local_classes_as_template_parameters" title="Local Classes as Template Parameters">Local
+ Classes as Template Parameters</a>
+</h3></div></div></div>
+<p>
+ This library uses a local class to implement the local functor object. However,
+ in ISO standard C++ a local classes, and therefore the local functor object,
+ cannot be passed as template parameter (for example 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 on C++03 and later standards. To work
+ around this limitation, this library investigated the following two tricks
+ (both these approaches can be extended to support eventual function default
+ parameters):
+ </p>
+<div class="orderedlist"><ol class="orderedlist" type="1">
+<li class="listitem">
+ The <span class="emphasis"><em>casting functor trick</em></span> uses a non-local functor
+ class that calls a static member function of the local class via a function
+ pointer. The static member function then calls the correct local function
+ body after type casting the object.
+ </li>
+<li class="listitem">
+ The <span class="emphasis"><em>virtual functor trick</em></span> uses a non-local virtual
+ base class for the local functor class. The correct implementation of
+ the <code class="computeroutput"><span class="keyword">operator</span><span class="special">()</span></code>
+ is called via polymorphism.
+ </li>
+</ol></div>
+<p>
+
+</p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</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">cassert</span><span class="special">></span>
+
+<span class="comment">// Casting Functor Trick
+</span><span class="keyword">struct</span> <span class="identifier">casting_func</span> <span class="special">{</span>
+ <span class="keyword">explicit</span> <span class="identifier">casting_func</span><span class="special">(</span><span class="keyword">void</span><span class="special">*</span> <span class="identifier">obj</span><span class="special">,</span> <span class="keyword">void</span> <span class="special">(*</span><span class="identifier">call</span><span class="special">)(</span><span class="keyword">void</span><span class="special">*,</span> <span class="keyword">const</span> <span class="keyword">double</span><span class="special">&)):</span>
+ <span class="identifier">obj_</span><span class="special">(</span><span class="identifier">obj</span><span class="special">),</span> <span class="identifier">call_</span><span class="special">(</span><span class="identifier">call</span><span class="special">)</span> <span class="special">{}</span>
+ <span class="keyword">inline</span> <span class="keyword">void</span> <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">const</span> <span class="keyword">double</span><span class="special">&</span> <span class="identifier">num</span><span class="special">)</span>
+ <span class="special">{</span> <span class="identifier">call_</span><span class="special">(</span><span class="identifier">obj_</span><span class="special">,</span> <span class="identifier">num</span><span class="special">);</span> <span class="special">}</span> <span class="comment">// function pointer call cannot be inlined
+</span><span class="keyword">private</span><span class="special">:</span>
+ <span class="keyword">void</span><span class="special">*</span> <span class="identifier">obj_</span><span class="special">;</span>
+ <span class="keyword">void</span> <span class="special">(*</span><span class="identifier">call_</span><span class="special">)(</span><span class="keyword">void</span><span class="special">*,</span> <span class="keyword">const</span> <span class="keyword">double</span><span class="special">&);</span>
+<span class="special">};</span>
+
+<span class="comment">// Virtual Functor Trick
+</span><span class="keyword">struct</span> <span class="identifier">func_interface</span> <span class="special">{</span>
+ <span class="keyword">inline</span> <span class="keyword">virtual</span> <span class="keyword">void</span> <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">const</span> <span class="keyword">double</span><span class="special">&)</span>
+ <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="comment">// virtual call cannot be inlined
+</span><span class="special">};</span>
+<span class="keyword">struct</span> <span class="identifier">virtual_func</span> <span class="special">{</span>
+ <span class="keyword">explicit</span> <span class="identifier">virtual_func</span><span class="special">(</span><span class="identifier">func_interface</span><span class="special">&</span> <span class="identifier">ref</span><span class="special">):</span> <span class="identifier">ptr_</span><span class="special">(&</span><span class="identifier">ref</span><span class="special">)</span> <span class="special">{}</span>
+ <span class="keyword">inline</span> <span class="keyword">void</span> <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">const</span> <span class="keyword">double</span><span class="special">&</span> <span class="identifier">num</span><span class="special">)</span>
+ <span class="special">{</span> <span class="special">(*</span><span class="identifier">ptr_</span><span class="special">)(</span><span class="identifier">num</span><span class="special">);</span> <span class="special">}</span>
+<span class="keyword">private</span><span class="special">:</span>
+ <span class="identifier">func_interface</span><span class="special">*</span> <span class="identifier">ptr_</span><span class="special">;</span>
+<span class="special">};</span>
+
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> <span class="special">{</span>
+ <span class="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">struct</span> <span class="identifier">local_add</span> <span class="special">:</span> <span class="identifier">func_interface</span> <span class="special">{</span>
+ <span class="keyword">explicit</span> <span class="identifier">local_add</span><span class="special">(</span><span class="keyword">double</span><span class="special">&</span> <span class="identifier">_sum</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">int</span><span class="special">&</span> <span class="identifier">_factor</span><span class="special">):</span>
+ <span class="identifier">sum_</span><span class="special">(</span><span class="identifier">_sum</span><span class="special">),</span> <span class="identifier">factor_</span><span class="special">(</span><span class="identifier">_factor</span><span class="special">)</span> <span class="special">{}</span>
+ <span class="keyword">inline</span> <span class="keyword">void</span> <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">const</span> <span class="keyword">double</span><span class="special">&</span> <span class="identifier">num</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">body</span><span class="special">(</span><span class="identifier">sum_</span><span class="special">,</span> <span class="identifier">factor_</span><span class="special">,</span> <span class="identifier">num</span><span class="special">);</span>
+ <span class="special">}</span>
+ <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">call</span><span class="special">(</span>
+ <span class="keyword">void</span><span class="special">*</span> <span class="identifier">obj</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">double</span><span class="special">&</span> <span class="identifier">num</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">local_add</span><span class="special">*</span> <span class="identifier">self</span> <span class="special">=</span> <span class="keyword">static_cast</span><span class="special"><</span><span class="identifier">local_add</span><span class="special">*>(</span><span class="identifier">obj</span><span class="special">);</span>
+ <span class="identifier">self</span><span class="special">-></span><span class="identifier">body</span><span class="special">(</span><span class="identifier">self</span><span class="special">-></span><span class="identifier">sum_</span><span class="special">,</span> <span class="identifier">self</span><span class="special">-></span><span class="identifier">factor_</span><span class="special">,</span> <span class="identifier">num</span><span class="special">);</span>
+ <span class="special">}</span>
+ <span class="keyword">private</span><span class="special">:</span>
+ <span class="keyword">double</span><span class="special">&</span> <span class="identifier">sum_</span><span class="special">;</span>
+ <span class="keyword">const</span> <span class="keyword">int</span><span class="special">&</span> <span class="identifier">factor_</span><span class="special">;</span>
+ <span class="keyword">inline</span> <span class="keyword">void</span> <span class="identifier">body</span><span class="special">(</span><span class="keyword">double</span><span class="special">&</span> <span class="identifier">sum</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">int</span><span class="special">&</span> <span class="identifier">factor</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">double</span><span class="special">&</span> <span class="identifier">num</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">sum</span> <span class="special">+=</span> <span class="identifier">factor</span> <span class="special">*</span> <span class="identifier">num</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="special">}</span> <span class="identifier">add_local</span><span class="special">(</span><span class="identifier">sum</span><span class="special">,</span> <span class="identifier">factor</span><span class="special">);</span>
+ <span class="identifier">casting_func</span> <span class="identifier">add_casting</span><span class="special">(&</span><span class="identifier">add_local</span><span class="special">,</span> <span class="special">&</span><span class="identifier">local_add</span><span class="special">::</span><span class="identifier">call</span><span class="special">);</span>
+ <span class="identifier">virtual_func</span> <span class="identifier">add_virtual</span><span class="special">(</span><span class="identifier">add_local</span><span class="special">);</span>
+
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="identifier">v</span><span class="special">(</span><span class="number">10</span><span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">fill</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="number">1.0</span><span class="special">);</span>
+
+<span class="comment">// std::for_each(v.begin(), v.end(), add_local); // Error but OK on C++03.
+</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">add_casting</span><span class="special">);</span> <span class="comment">// OK.
+</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">add_virtual</span><span class="special">);</span> <span class="comment">// OK.
+</span>
+ <span class="identifier">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>
+<p>
+ The casting functor trick had slightly better run-time performances than
+ the virtual functor trick so the current implementation of this library uses
+ the casting functor trick. However, both methods do not 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)
+ that can only be resolved at run-time. Therefore, on C++03 compilers this
+ library generates code that passes the local class functor as template parameter
+ directly without using neither one of these two tricks in order to take full
+ advantage of compiler optimizations that inline the local function calls.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
<a name="boost_local.Implementation.local_blocks"></a><a class="link" href="Implementation.html#boost_local.Implementation.local_blocks" title="Local Blocks">Local Blocks</a>
</h3></div></div></div>
<p>
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-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -81,7 +81,8 @@
<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">
+<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>
@@ -89,7 +90,22 @@
and <code class="computeroutput"><span class="identifier">_</span><span class="special">...</span></code>
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></ul></div>
+ </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>
</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-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -115,12 +115,12 @@
<span class="special">...</span> <span class="special">}</span></code>
using the usual C++ syntax. The body is specified outside any of the macros
so eventual compiler error messages and related line numbers retain their
- usual meaning. <sup>[<a name="id866832" href="#ftn.id866832" class="footnote">2</a>]</sup>
+ usual meaning. <sup>[<a name="id866814" href="#ftn.id866814" class="footnote">2</a>]</sup>
</p>
<p>
The macro <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code>
is used to end the local function definition and to specify the local function
- name. <sup>[<a name="id866869" href="#ftn.id866869" class="footnote">3</a>]</sup>
+ name. <sup>[<a name="id866850" href="#ftn.id866850" class="footnote">3</a>]</sup>
</p>
<p>
For example, let's program a local function named <code class="computeroutput"><span class="identifier">add</span></code>
@@ -366,7 +366,7 @@
This library also allows to specify default values for the local function
parameters. However, the usual C++ syntax for default parameters that uses
the assignment symbol <code class="computeroutput"><span class="special">=</span></code> cannot
- be used. <sup>[<a name="id868891" href="#ftn.id868891" class="footnote">4</a>]</sup> The keyword <code class="computeroutput"><span class="keyword">default</span></code>
+ be used. <sup>[<a name="id868873" href="#ftn.id868873" class="footnote">4</a>]</sup> The keyword <code class="computeroutput"><span class="keyword">default</span></code>
is used instead:
</p>
<div class="informaltable"><table class="table">
@@ -508,7 +508,7 @@
variables, the object <code class="computeroutput"><span class="keyword">this</span></code>,
etc) can be bound to a local function declaration. The types of bound variables
are automatically deduced by this library using Boost.Typeof.
- <sup>[<a name="id870252" href="#ftn.id870252" class="footnote">5</a>]</sup>
+ <sup>[<a name="id870233" href="#ftn.id870233" class="footnote">5</a>]</sup>
</p>
<div class="important"><table border="0" summary="Important">
<tr>
@@ -525,7 +525,7 @@
</table></div>
<p>
This library introduces the new "keyword" <code class="computeroutput"><span class="identifier">bind</span></code>
- <sup>[<a name="id870333" href="#ftn.id870333" class="footnote">6</a>]</sup> which is used in place of the parameter type to specify the name
+ <sup>[<a name="id870315" href="#ftn.id870315" class="footnote">6</a>]</sup> which is used in place of the parameter type to specify the name
of a variable in scope to bind. The variable can be bound by value:
</p>
<pre class="programlisting"><span class="identifier">bind</span> <span class="emphasis"><em>variable-name</em></span> <span class="comment">// Bind by value.
@@ -572,7 +572,7 @@
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++0x
- lambda</a> functions). <sup>[<a name="id870898" href="#ftn.id870898" class="footnote">7</a>]</sup> As with passing parameters to usual C++ functions, programmers
+ lambda</a> functions). <sup>[<a name="id870880" href="#ftn.id870880" class="footnote">7</a>]</sup> As with passing parameters to usual C++ functions, programmers
might want to bind variables of complex types by (constant) reference instead
than by value to avoid expensive copy operations when these variables are
bound to a local function.
@@ -653,7 +653,7 @@
</tr></tbody>
</table></div>
<a name="boost_local.Tutorial.Binding.binding_the_object__code__phrase_role__keyword__this__phrase___code_"></a><h6>
-<a name="id871745"></a>
+<a name="id871726"></a>
<a class="link" href="Tutorial.html#boost_local.Tutorial.Binding.binding_the_object__code__phrase_role__keyword__this__phrase___code_">Binding
the Object <code class="computeroutput"><span class="keyword">this</span></code></a>
</h6>
@@ -705,12 +705,12 @@
<p>
When the object <code class="computeroutput"><span class="keyword">this</span></code> is bound
to a local function, the local function body must use the special symbol
- <code class="computeroutput"><span class="identifier">this_</span></code> (instead of <code class="computeroutput"><span class="keyword">this</span></code>) to access the bound object. <sup>[<a name="id872067" href="#ftn.id872067" class="footnote">8</a>]</sup>
+ <code class="computeroutput"><span class="identifier">this_</span></code> (instead of <code class="computeroutput"><span class="keyword">this</span></code>) to access the bound object. <sup>[<a name="id872048" href="#ftn.id872048" class="footnote">8</a>]</sup>
</p>
<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="id872161" href="#ftn.id872161" 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="id872142" href="#ftn.id872142" 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="id875470" href="#ftn.id875470" class="footnote">10</a>]</sup>
+ body and it does not return the enclosing function. <sup>[<a name="id875460" href="#ftn.id875460" 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="id876683" href="#ftn.id876683" class="footnote">11</a>]</sup>
+ does not terminate because of an uncaught exception. <sup>[<a name="id876673" href="#ftn.id876673" 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="id877939" href="#ftn.id877939" 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="id877929" href="#ftn.id877929" 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="id878222" href="#ftn.id878222" class="footnote">13</a>]</sup>
+ the Reference section): <sup>[<a name="id878211" href="#ftn.id878211" 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>
@@ -1254,20 +1254,20 @@
</div>
<div class="footnotes">
<br><hr width="100" align="left">
-<div class="footnote"><p><sup>[<a id="ftn.id866832" href="#id866832" class="para">2</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id866814" href="#id866814" class="para">2</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> If the local function body
were instead passed as a macro parameter, it would be expanded on a single
line of code (because macros always expand as a single line of code). Therefore,
eventual compiler error line numbers would all report the same value and
would no longer be useful to pinpoint the error.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id866869" href="#id866869" class="para">3</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id866850" href="#id866850" class="para">3</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> The local function name must
be passed to the macro <code class="computeroutput"><a class="link" href="../BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a></code>
ending the function definition so this macro can declare a local variable
with the local function name to hold the local functor object.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id868891" href="#id868891" class="para">4</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id868873" href="#id868873" class="para">4</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> The assignment symbol <code class="computeroutput"><span class="special">=</span></code> cannot be used to specify default parameter
values because default values are not part of the parameter type so they
cannot be handled using template metaprogamming. Default parameter values
@@ -1277,7 +1277,7 @@
it counts the number of default values to provide the correct set of call
operators for the local functor object.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id870252" href="#id870252" class="para">5</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id870233" href="#id870233" class="para">5</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> By binding a variable in scope,
the local function declaration is specifying that such a variable should
be accessible within the local function body regardless of its type. Semantically,
@@ -1290,7 +1290,7 @@
This is especially useful for maintenance so if a bound variable type is
changed, the local function declaration does not have to change.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id870333" href="#id870333" class="para">6</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id870315" href="#id870315" class="para">6</a>] </sup>
The token <code class="computeroutput"><span class="identifier">bind</span></code> is not a
real keyword of the C++ language. This library parses <code class="computeroutput"><span class="identifier">bind</span></code>
during macro expansion using preprocessor metaprogramming. Therefore,
@@ -1299,7 +1299,7 @@
within the syntax defined by the macros of this library -- thus it is referred
to as a "keyword" only within quotes.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id870898" href="#id870898" class="para">7</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id870880" href="#id870880" class="para">7</a>] </sup>
An historical note: Constant binding of variables in scope was the main
use case that originally motivated the authors in developing this library.
The authors needed to locally create a chuck of code to assert some correctness
@@ -1314,7 +1314,7 @@
generates an error because the bound variable is of <code class="computeroutput"><span class="keyword">const</span></code>
type within the local function body.
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id872067" href="#id872067" class="para">8</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id872048" href="#id872048" class="para">8</a>] </sup>
<span class="bold"><strong>Rationale.</strong></span> This limitation comes from
the fact that <code class="computeroutput"><span class="keyword">this</span></code> is a
reserved C++ keyword so it cannot be used as the name of the internal
@@ -1328,7 +1328,7 @@
behaviour of <code class="computeroutput"><span class="keyword">static_cast</span></code></a>
(which might not work on all platforms at the cost of portability).
</p></div>
-<div class="footnote"><p><sup>[<a id="ftn.id872161" href="#id872161" class="para">9</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id872142" href="#id872142" 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 +1341,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.id875470" href="#id875470" class="para">10</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id875460" href="#id875460" 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 +1359,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.id876683" href="#id876683" class="para">11</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id876673" href="#id876673" 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 +1370,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.id877939" href="#id877939" class="para">12</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id877929" href="#id877929" 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 +1397,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.id878222" href="#id878222" class="para">13</a>] </sup>
+<div class="footnote"><p><sup>[<a id="ftn.id878211" href="#id878211" 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-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -27,7 +27,7 @@
</h3></div></div></div>
<div><p class="copyright">Copyright © 2009 -2011 Lorenzo Caminiti</p></div>
<div><div class="legalnotice">
-<a name="id863763"></a><p>
+<a name="id808787"></a><p>
Use, modification, and distribution is subject to the Boost Software License,
Version 1.0 (see accompanying file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
</p>
@@ -109,7 +109,7 @@
</li>
</ul></div>
<a name="boost_local.Introduction.two_syntaxes"></a><h6>
-<a name="id808269"></a>
+<a name="id810167"></a>
<a class="link" href="index.html#boost_local.Introduction.two_syntaxes">Two Syntaxes</a>
</h6>
<p>
@@ -142,7 +142,7 @@
of both syntaxes.
</p>
<a name="boost_local.Introduction.an_example"></a><h6>
-<a name="id810367"></a>
+<a name="id810312"></a>
<a class="link" href="index.html#boost_local.Introduction.an_example">An Example</a>
</h6>
<p>
@@ -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: March 30, 2011 at 18:18:10 GMT</small></p></td>
+<td align="left"><p><small>Last revised: April 24, 2011 at 02:05:22 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
Modified: sandbox/local/libs/local/doc/html/reference.html
==============================================================================
--- sandbox/local/libs/local/doc/html/reference.html (original)
+++ sandbox/local/libs/local/doc/html/reference.html 2011-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -71,7 +71,8 @@
<a class="link" href="BOOST_LOCAL_FUNCTION_PARAMS.html" title="Macro BOOST_LOCAL_FUNCTION_PARAMS">BOOST_LOCAL_FUNCTION_PARAMS</a>(parameters)
<a class="link" href="BOOST_LOCAL_FUNCTION_PARAMS_TPL.html" title="Macro BOOST_LOCAL_FUNCTION_PARAMS_TPL">BOOST_LOCAL_FUNCTION_PARAMS_TPL</a>(parameters)
-<a class="link" href="BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a>(name)</pre>
+<a class="link" href="BOOST_LOCAL_FUNCTION_NAME.html" title="Macro BOOST_LOCAL_FUNCTION_NAME">BOOST_LOCAL_FUNCTION_NAME</a>(name)
+<a class="link" href="BOOST_LOCAL_FUNCTION_NAME_OPTIMIZED.html" title="Macro BOOST_LOCAL_FUNCTION_NAME_OPTIMIZED">BOOST_LOCAL_FUNCTION_NAME_OPTIMIZED</a>(name)</pre>
<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span>
<span class="keyword">namespace</span> <span class="identifier">local</span> <span class="special">{</span>
<span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> F<span class="special">,</span> <span class="identifier">size_t</span> defaults <span class="special">=</span> <span class="number">0</span><span class="special">></span> <span class="keyword">struct</span> <a class="link" href="boost/local/function.html" title="Struct template function">function</a><span class="special">;</span>
Modified: sandbox/local/libs/local/doc/html/standalone_HTML.manifest
==============================================================================
--- sandbox/local/libs/local/doc/html/standalone_HTML.manifest (original)
+++ sandbox/local/libs/local/doc/html/standalone_HTML.manifest 2011-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -16,6 +16,7 @@
BOOST_LOCAL_FUNCTION_PARAMS.html
BOOST_LOCAL_FUNCTION_PARAMS_TPL.html
BOOST_LOCAL_FUNCTION_NAME.html
+BOOST_LOCAL_FUNCTION_NAME_OPTIMIZED.html
BOOST_LOCAL_TYPEOF.html
BOOST_IDENTITY_TYPE.html
BOOST_IDENTITY_VALUE.html
Modified: sandbox/local/libs/local/doc/qbk/alternatives.qbk
==============================================================================
--- sandbox/local/libs/local/doc/qbk/alternatives.qbk (original)
+++ sandbox/local/libs/local/doc/qbk/alternatives.qbk 2011-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -69,38 +69,10 @@
[ No. ]
[ Yes, using `let` which also allows to bind by constant reference. ]
]
-[
- [ ['Compile-Time]
-[footnote
-Compilation times have been measured in seconds using the Linux command [^$ time g++ -O3 -Wall -Wextra -I<BOOST_DIR> <CPP_FILE>] for the examples listed below for all the different approaches.
-The [^real] time is the overall time that took to execute the command.
-The actual time values can change from execution to execution therefore they have been measured 3 times and the time reported it the one with the middle [^real] time value.
-The time values are machine dependent so they have no absolute meaning but they can be used in this context to compare the performances of the different approaches relative to each other (because all these values were measured on the same system).
-]
- ]
- [ 0 seconds ]
- [ 0 seconds ]
- [ 0 seconds ]
- [ 0 seconds ]
- [ 0 seconds ]
- [ 0 seconds ]
-]
-[
- [ ['Run-Time]
-[footnote
-run times have been measured in seconds using the Linux command [^$ time <COMPILED_PROGRAM>] for the compiled examples listed below for all the different approaches.
-The same statistical approach as for compilation time was followed.
-]
- ]
- [ 0 seconds ]
- [ 0 seconds ]
- [ 0 seconds ]
- [ 0 seconds ]
- [ 0 seconds ]
- [ 0 seconds ]
-]
]
+[h5 Examples]
+
For example, using this library local functions:
[table
@@ -128,6 +100,73 @@
[add_using_boost_phoenix_cpp]
+[h5 Profiling]
+
+The following table compares compile-time, binary size, and run-time among the different alternatives.
+
+This library has compile-times and generates binary sizes similar to the ones of the other approaches.
+This library run-times on ISO C++ compliant compilers (see "__Boost_Local__ Compliant" below) were measured to be similar to "Local Functor" but larger than other approaches like "Global Functor", "__Boost_Lambda__", or "__Boost_Phoenix__" when compiler optimization is enabled.
+However, on C++03 compilers (e.g., MSVC) this library generates optimized code (see "__Boost_Local__" below) that runs as fast as the fastest of the other approaches.
+Finally, this library run-times are always among the fastest when no compiler optimization is used.
+
+[note
+This is because on non C++03 compilers (e.g., GCC) this library needs to use a function pointer in order to pass the local functor class as a template parameter (see the __Implementation__ section).
+This function pointer prevents the compiler from inlining all the function calls while the functors used by other approaches like "__Boost_Lambda__" and "__Boost_Phoenix__" allows the compiler to inline all the function calls.
+
+This run-time performance cost on non C++03 compilers might or not be a problem depending on the performance requirements of your application.
+For example, your 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 your overall program run-time.
+]
+
+Finally, note that a very simple local function body with only one instruction was used for the profiling presented here (see files
+[@../../example/profile_boost_local.cpp =profile_boost_local.cpp=],
+[@../../example/profile_boost_local_for_loop.cpp =profile_boost_local_for_loop.cpp=],
+[@../../example/profile_boost_local_optimized.cpp =profile_boost_local_optimized.cpp=],
+[@../../example/profile_local_functor.cpp =profile_local_functor.cpp=],
+[@../../example/profile_global_functor.cpp =profile_global_functor.cpp=],
+[@../../example/profile_0x_lambda.cpp =profile_0x_lambda.cpp=],
+[@../../example/profile_boost_lambda.cpp =profile_boost_lambda.cpp=], and
+[@../../example/profile_boost_phoenix.cpp =profile_boost_phoenix.cpp=]).
+The authors have not studied how this library and the other approaches will perform with respect to each other when a more complex set of instructions is programmed for the local function body.
+
+[table
+[
+ [ =bjam release= on MSVC 8.0 (maximum optimization =/O2 /Ob2=)]
+ [ =bjam debug= on MSVC 8.0 (no optimization =/O0 /Ob0=)]
+]
+[
+ [
+The local function was called =1e8= times to add together all the elements of a vector.
+The run-time was measured using __Boost_Chrono__ and averaged over =100= executions of the vector summation (see the relative =profile_...= example files).
+ ]
+ [
+The local function was called =1e8= times to add together all the elements of a vector.
+The run-time was measured using __Boost_Chrono__ and averaged over =1= execution of the vector summation (see the relative =profile_...= example files).
+ ]
+]
+[
+ [ [$../../example/profile_msvc-8.0_release.png [width 7in] [height 10in]] ]
+ [ [$../../example/profile_msvc-8.0_debug.png [width 7in] [height 10in]] ]
+]
+[
+ [
+Commands used to measure compile-time, binary size, and run-time from the library example directory:
+``
+> python chrono.py bjam release <PROGRAM>
+> size <PROGRAM> # Cygwin command
+> <PROGRAM> 100000000 100
+``
+ ]
+ [
+Commands used to measure compile-time, binary size, and run-time from the library example directory:
+``
+> python chrono.py bjam debug <PROGRAM>
+> size <PROGRAM> # Cygwin command
+> <PROGRAM> 100000000 1
+``
+ ]
+]
+]
+
[endsect]
[section Local Blocks]
Modified: sandbox/local/libs/local/doc/qbk/implementation.qbk
==============================================================================
--- sandbox/local/libs/local/doc/qbk/implementation.qbk (original)
+++ sandbox/local/libs/local/doc/qbk/implementation.qbk 2011-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -20,6 +20,26 @@
[endsect]
+[section Local Classes as Template Parameters]
+
+This library uses a local class to implement the local functor object.
+However, in ISO standard C++ a local classes, and therefore the local functor object, cannot be passed as template parameter (for example to the `std::for_each` algorithm), this is instead possible on C++03 and later standards.
+To work around this limitation, this library investigated the following two tricks (both tricks can be extended to support eventual function default parameters):
+
+# The /casting functor trick/ uses a non-local functor class that calls a static member function of the local class via a function pointer.
+The static member function then calls the correct local function body after type casting the object.
+
+# The /virtual functor trick/ uses a non-local virtual base class for the local functor class.
+The correct implementation of the `operator()` is called via polymorphism.
+
+[tparam_trick_cpp]
+
+The casting functor trick had slightly better run-time performances than the virtual functor trick so the current implementation of this library uses the casting functor trick.
+However, both tricks do not 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) that can only be resolved at run-time.
+Therefore, on C++03 compilers this library generates code that passes the local class functor as template parameter directly without using neither one of these two tricks in order to take full advantage of compiler optimizations that inline the local function calls.
+
+[endsect]
+
[section Local Blocks]
The expansion of the local block macros for the main local block example presented in the __Tutorial__ section generates code equivalent to the following:
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-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -20,6 +20,7 @@
]
[def __Boost__ [@http://www.boost.org/ Boost]]
+[def __Boost_Local__ [@http://www.boost.org/doc/libs/release/libs/local/doc/html/index.html Boost.Local]]
[def __Boost_ScopeExit__ [@http://www.boost.org/doc/libs/release/libs/scope_exit/doc/html/index.html Boost.ScopeExit]]
[def __Boost_Lambda__ [@http://www.boost.org/doc/libs/release/doc/html/lambda.html Boost.Lambda]]
[def __Boost_Phoenix__ [@http://www.boost.org/doc/libs/release/libs/spirit/phoenix/index.html Boost.Phoenix]]
@@ -30,6 +31,7 @@
[def __Boost_Typeof__ [@http://www.boost.org/doc/libs/release/doc/html/typeof.html Boost.Typeof]]
[def __Boost_Function__ [@http://www.boost.org/doc/libs/release/doc/html/function.html Boost.Function]]
[def __Boost_TypeTraits__ [@http://www.boost.org/doc/libs/release/libs/type_traits/doc/html/index.html Boost.TypeTraits]]
+[def __Boost_Chrono__ [@http://www.boost.org/doc/libs/release/libs/chrono/doc/html/index.html Boost.Chrono]]
[def __CPP0x_lambda__ [@http://en.wikipedia.org/wiki/C%2B%2B0x#Lambda_functions_and_expressions C++0x lambda]]
[def __LISP__ [@http://en.wikipedia.org/wiki/Lisp_(programming_language) LISP]]
[def __Contractpp__ [@http://sourceforge.net/projects/contractpp Contract++]]
@@ -134,6 +136,7 @@
[import ../../example/factorial_impl.cpp]
[import ../../example/add_block_impl.cpp]
[import ../../example/add_exit_impl.cpp]
+[import ../../example/tparam_trick.cpp]
[import ../../example/add_using_boost_local.cpp]
[import ../../example/add_using_boost_local_va.cpp]
[import ../../example/add_using_local_functor.cpp]
Modified: sandbox/local/libs/local/example/Jamfile.jam
==============================================================================
--- sandbox/local/libs/local/example/Jamfile.jam (original)
+++ sandbox/local/libs/local/example/Jamfile.jam 2011-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -104,6 +104,8 @@
exe world_exit : world_exit.cpp ;
exe world_exit_va : world_exit_va.cpp ;
+exe tparam_trick : tparam_trick.cpp ;
+
exe add_using_boost_local : add_using_boost_local.cpp ;
exe add_using_boost_local_va : add_usign_boost_local_va.cpp ;
exe add_using_local_functor : add_using_local_functor.cpp ;
@@ -112,5 +114,11 @@
exe add_using_boost_lambda : add_using_boost_lambda.cpp ;
exe add_using_boost_phoenix : add_using_boost_phoenix.cpp ;
-exe l10 : l10.cpp ;
+exe profile_boost_local : profile_boost_local.cpp ;
+exe profile_boost_local_optimized : profile_boost_local_optimized.cpp ;
+exe profile_boost_local_for_loop : profile_boost_local_for_loop.cpp ;
+exe profile_local_functor : profile_local_functor.cpp ;
+exe profile_global_functor : profile_global_functor.cpp ;
+exe profile_boost_lambda : profile_boost_lambda.cpp ;
+exe profile_boost_phoenix : profile_boost_phoenix.cpp ;
Modified: sandbox/local/libs/local/example/benchmark_boost_lambda.cpp
==============================================================================
--- sandbox/local/libs/local/example/benchmark_boost_lambda.cpp (original)
+++ sandbox/local/libs/local/example/benchmark_boost_lambda.cpp 2011-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -18,13 +18,13 @@
std::fill(v.begin(), v.end(), 1.0);
for (size_t n = 0; n < N; ++n) {
- std::for_each(v.begin(), v.end(), (
- sum += factor * _1
- ));
+// std::for_each(v.begin(), v.end(), (
+// sum += factor * _1
+// ));
}
std::cout << sum << std::endl;
- assert(sum == N * S);
+// assert(sum == N * S);
return 0;
}
Modified: sandbox/local/libs/local/example/benchmark_boost_local.cpp
==============================================================================
--- sandbox/local/libs/local/example/benchmark_boost_local.cpp (original)
+++ sandbox/local/libs/local/example/benchmark_boost_local.cpp 2011-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -1,31 +1,42 @@
+#include <boost/chrono.hpp>
#include <boost/local/function.hpp>
#include <vector>
#include <algorithm>
#include <iostream>
-#include <cassert>
+#include "benchmark_helpers.hpp"
-#define N 1e4
-#define S N * 1e2
+int main(int argc, char* argv[]) {
+ boost::chrono::duration<double> sec;
+ unsigned long loop; unsigned long size; bool verbose; double n;
+ begin(argc, argv, loop, size, verbose, n);
-int main() {
double sum = 0.0;
int factor = 1;
+ boost::chrono::system_clock::time_point start =
+ boost::chrono::system_clock::now();
void BOOST_LOCAL_FUNCTION_PARAMS( (const double& num)
(bind& sum) (const bind& factor) ) {
sum += factor * num;
} BOOST_LOCAL_FUNCTION_NAME(add)
+ sec += boost::chrono::system_clock::now() - start;
+ if (verbose) {
+ std::clog << "declaration run-time = " << sec.count() << "s" <<
+ std::endl;
+ }
- std::vector<double> v(S);
+ std::vector<double> v(size);
std::fill(v.begin(), v.end(), 1.0);
- for (size_t n = 0; n < N; ++n) {
+ for (unsigned long i = 0; i < loop; ++i) {
+ boost::chrono::system_clock::time_point start =
+ boost::chrono::system_clock::now();
std::for_each(v.begin(), v.end(), add);
+ sec += boost::chrono::system_clock::now() - start;
}
- std::cout << sum << std::endl;
- assert(sum == N * S);
+ end(verbose, n, sum, sec);
return 0;
}
Modified: sandbox/local/libs/local/example/benchmark_global_functor.cpp
==============================================================================
--- sandbox/local/libs/local/example/benchmark_global_functor.cpp (original)
+++ sandbox/local/libs/local/example/benchmark_global_functor.cpp 2011-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -27,11 +27,11 @@
global_add add(sum, factor);
for (size_t n = 0; n < N; ++n) {
- std::for_each(v.begin(), v.end(), add);
+// std::for_each(v.begin(), v.end(), add);
}
std::cout << sum << std::endl;
- assert(sum == N * S);
+// assert(sum == N * S);
return 0;
}
Modified: sandbox/local/libs/local/example/benchmark_local_functor.cpp
==============================================================================
--- sandbox/local/libs/local/example/benchmark_local_functor.cpp (original)
+++ sandbox/local/libs/local/example/benchmark_local_functor.cpp 2011-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -2,18 +2,16 @@
#include <iostream>
#include <vector>
#include <algorithm>
+#include <cmath>
#include <cassert>
-#define N 1e4
-#define S N * 1e2
+int main(int argc, char* argv[]) {
+ assert(argc == 2);
+ unsigned long n = sqrt(double(atol(argv[1])));
-int main() {
double sum = 0.0;
int factor = 1;
- std::vector<double> v(S);
- std::fill(v.begin(), v.end(), 1.0);
-
struct local_add {
local_add(double& _sum, int _factor): sum(_sum), factor(_factor) {}
void operator()(const double& num) {
@@ -25,12 +23,14 @@
};
local_add add(sum, factor);
- for (size_t n = 0; n < N; ++n) {
- for (size_t i = 0; i < v.size(); ++i) add(v[i]); // Can't use for_each.
+ std::vector<double> v(n);
+ std::fill(v.begin(), v.end(), 1.0);
+ for (unsigned long i = 0; i < n; ++i) {
+// for (size_t j = 0; j < v.size(); ++j) add(v[j]); // Can't use for_each.
}
std::cout << sum << std::endl;
- assert(sum == N * S);
+// assert(sum == n * n);
return 0;
}
Modified: sandbox/local/libs/local/example/tparam_trick.10.cpp
==============================================================================
--- sandbox/local/libs/local/example/tparam_trick.10.cpp (original)
+++ sandbox/local/libs/local/example/tparam_trick.10.cpp 2011-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -1,17 +1,11 @@
// Tricks to "pass" a local class as a template parameter.
-// compile-time: $ time g++ -O3 -Wall <THIS_FILE>
-// run-time: $ time ./a
-
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
-#define N 1e4
-#define S N * 1e2
-
// Trick A: Virtual Base
struct func_if {
Modified: sandbox/local/libs/local/example/tparam_trick.cpp
==============================================================================
--- sandbox/local/libs/local/example/tparam_trick.cpp (original)
+++ sandbox/local/libs/local/example/tparam_trick.cpp 2011-04-23 22:21:20 EDT (Sat, 23 Apr 2011)
@@ -1,53 +1,70 @@
+// Tricks to "pass" a local class as a template parameter.
+
+//[tparam_trick_cpp
#include <iostream>
#include <vector>
#include <algorithm>
+#include <cassert>
-#define N 10000
-
-template<typename R, typename A0>
-struct abstract_function {
- virtual R operator()(A0) = 0;
+// Casting Functor Trick
+struct casting_func {
+ explicit casting_func(void* obj, void (*call)(void*, const double&)):
+ obj_(obj), call_(call) {}
+ inline void operator()(const double& num)
+ { call_(obj_, num); } // function pointer call cannot be inlined
+private:
+ void* obj_;
+ void (*call_)(void*, const double&);
};
-template<typename R, typename A0>
-struct function {
- function(abstract_function<R, A0>& ref): ptr_(&ref) {}
- R operator()(A0 a0) { return (*ptr_)(a0); }
+// Virtual Functor Trick
+struct func_interface {
+ inline virtual void operator()(const double&)
+ = 0; // virtual call cannot be inlined
+};
+struct virtual_func {
+ explicit virtual_func(func_interface& ref): ptr_(&ref) {}
+ inline void operator()(const double& num)
+ { (*ptr_)(num); }
private:
- abstract_function<R, A0>* ptr_;
+ func_interface* ptr_;
};
int main() {
double sum = 0.0;
int factor = 10;
- struct add_function: abstract_function<void, const double&> {
- add_function(double& _sum, const int& _factor):
+ struct local_add : func_interface {
+ explicit local_add(double& _sum, const int& _factor):
sum_(_sum), factor_(_factor) {}
- void operator()(const double& num) { return body(num, sum_, factor_); }
+ inline void operator()(const double& num) {
+ body(sum_, factor_, num);
+ }
+ inline static void call(
+ void* obj, const double& num) {
+ local_add* self = static_cast<local_add*>(obj);
+ self->body(self->sum_, self->factor_, num);
+ }
private:
double& sum_;
const int& factor_;
- void body(const double& num, double& sum, const int& factor) {
+ inline void body(double& sum, const int& factor, const double& num) {
sum += factor * num;
}
- };
- add_function functor_add(sum, factor);
- function<void, const double&> add(functor_add);
+ } add_local(sum, factor);
+ casting_func add_casting(&add_local, &local_add::call);
+ virtual_func add_virtual(add_local);
- std::vector<double> v(N * 100);
- std::fill(v.begin(), v.end(), 10);
+ std::vector<double> v(10);
+ std::fill(v.begin(), v.end(), 1.0);
- for (size_t n = 0; n < N; ++n) {
- for (size_t i = 0; i < v.size(); ++i) {
-// functor_add(v[i]); // (1)
- add(v[i]); // (2)
- }
- // std::for_each(v.begin(), v.end(), add); // (3) OK add as tparam!
- }
+// std::for_each(v.begin(), v.end(), add_local); // Error but OK on C++03.
+ std::for_each(v.begin(), v.end(), add_casting); // OK.
+ std::for_each(v.begin(), v.end(), add_virtual); // OK.
std::cout << sum << std::endl;
return 0;
}
+//]
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