Split Utility/IdentityType and Functional/OverloadedFunction tests into smaller tests.

Updated docs for ScopeExit, LocalFunction, Utility/IdentityType, and Functional/OverloadedFunction.

[SVN r77484]
This commit is contained in:
Lorenzo Caminiti
2012-03-22 20:54:20 +00:00
parent 6932e9b1dc
commit b2dd5d8ac5
14 changed files with 167 additions and 121 deletions

View File

@ -33,7 +33,7 @@
</span>BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX</pre></div> </span>BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX</pre></div>
<div class="refsect1"> <div class="refsect1">
<a name="id833145"></a><h2>Description</h2> <a name="id872024"></a><h2>Description</h2>
<p>If this macro is left undefined by the user, it has a default value of 5 (increasing this number might increase compilation time). When specified by the user, this macro must be a non-negative integer number.</p> <p>If this macro is left undefined by the user, it has a default value of 5 (increasing this number might increase compilation time). When specified by the user, this macro must be a non-negative integer number.</p>
<p><span class="bold"><strong>See:</strong></span> <a class="link" href="boost_functional_overloadedfunction/Getting_Started.html" title="Getting Started"> Getting Started</a>, <code class="computeroutput"><a class="link" href="boost/overloaded_function.html" title="Class template overloaded_function">boost::overloaded_function</a></code>. </p> <p><span class="bold"><strong>See:</strong></span> <a class="link" href="boost_functional_overloadedfunction/Getting_Started.html" title="Getting Started"> Getting Started</a>, <code class="computeroutput"><a class="link" href="boost/overloaded_function.html" title="Class template overloaded_function">boost::overloaded_function</a></code>. </p>
</div> </div>

View File

@ -33,7 +33,7 @@
</span>BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX</pre></div> </span>BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX</pre></div>
<div class="refsect1"> <div class="refsect1">
<a name="id833202"></a><h2>Description</h2> <a name="id872082"></a><h2>Description</h2>
<p>If this macro is left undefined by the user, it has a default value of 5 (increasing this number might increase compilation time). When defined by the user, this macro must be an integer number greater or equal than 2 (because at least two distinct functions need to be specified in order to define an overload).</p> <p>If this macro is left undefined by the user, it has a default value of 5 (increasing this number might increase compilation time). When defined by the user, this macro must be an integer number greater or equal than 2 (because at least two distinct functions need to be specified in order to define an overload).</p>
<p><span class="bold"><strong>See:</strong></span> <a class="link" href="boost_functional_overloadedfunction/Getting_Started.html" title="Getting Started"> Getting Started</a>, <code class="computeroutput"><a class="link" href="boost/overloaded_function.html" title="Class template overloaded_function">boost::overloaded_function</a></code>. </p> <p><span class="bold"><strong>See:</strong></span> <a class="link" href="boost_functional_overloadedfunction/Getting_Started.html" title="Getting Started"> Getting Started</a>, <code class="computeroutput"><a class="link" href="boost/overloaded_function.html" title="Class template overloaded_function">boost::overloaded_function</a></code>. </p>
</div> </div>

View File

@ -36,7 +36,7 @@
<a class="link" href="overloaded_function.html" title="Class template overloaded_function">overloaded_function</a><span class="special">&lt;</span> <span class="identifier">__function_type__</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span><span class="special">,</span> <span class="identifier">__function_type__</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span><span class="special">,</span><span class="special">...</span><span class="special">&gt;</span> <a class="link" href="overloaded_function.html" title="Class template overloaded_function">overloaded_function</a><span class="special">&lt;</span> <span class="identifier">__function_type__</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span><span class="special">,</span> <span class="identifier">__function_type__</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span><span class="special">,</span><span class="special">...</span><span class="special">&gt;</span>
<span class="identifier">make_overloaded_function</span><span class="special">(</span><span class="identifier">F1</span> f1<span class="special">,</span> <span class="identifier">F2</span> f2<span class="special">,</span> <span class="special">...</span><span class="special">)</span><span class="special">;</span></pre></div> <span class="identifier">make_overloaded_function</span><span class="special">(</span><span class="identifier">F1</span> f1<span class="special">,</span> <span class="identifier">F2</span> f2<span class="special">,</span> <span class="special">...</span><span class="special">)</span><span class="special">;</span></pre></div>
<div class="refsect1"> <div class="refsect1">
<a name="id832964"></a><h2>Description</h2> <a name="id871843"></a><h2>Description</h2>
<p>This function template creates and returns an <code class="computeroutput"><code class="computeroutput"><a class="link" href="overloaded_function.html" title="Class template overloaded_function">overloaded_function</a></code></code> function object that overloads all the specified functions <code class="computeroutput">f1</code>, <code class="computeroutput">f2</code>, etc.</p> <p>This function template creates and returns an <code class="computeroutput"><code class="computeroutput"><a class="link" href="overloaded_function.html" title="Class template overloaded_function">overloaded_function</a></code></code> function object that overloads all the specified functions <code class="computeroutput">f1</code>, <code class="computeroutput">f2</code>, etc.</p>
<p>The function types are internally determined from the template parameter types so they do not need to be explicitly specified. Therefore, this function template usually has a more concise syntax when compared with <code class="computeroutput"><code class="computeroutput"><a class="link" href="overloaded_function.html" title="Class template overloaded_function">overloaded_function</a></code></code>. This is especially useful when the explicit type of the returned <code class="computeroutput"><code class="computeroutput"><a class="link" href="overloaded_function.html" title="Class template overloaded_function">overloaded_function</a></code></code> does not need to be known (e.g., when used with Boost.Typeof's <code class="computeroutput">BOOST_AUTO</code> (or C++11 <code class="computeroutput">auto</code>) or when the overloaded function object is handled using a function template parameter, see the <a class="link" href="../boost_functional_overloadedfunction/Tutorial.html" title="Tutorial">Tutorial</a> section).</p> <p>The function types are internally determined from the template parameter types so they do not need to be explicitly specified. Therefore, this function template usually has a more concise syntax when compared with <code class="computeroutput"><code class="computeroutput"><a class="link" href="overloaded_function.html" title="Class template overloaded_function">overloaded_function</a></code></code>. This is especially useful when the explicit type of the returned <code class="computeroutput"><code class="computeroutput"><a class="link" href="overloaded_function.html" title="Class template overloaded_function">overloaded_function</a></code></code> does not need to be known (e.g., when used with Boost.Typeof's <code class="computeroutput">BOOST_AUTO</code> (or C++11 <code class="computeroutput">auto</code>) or when the overloaded function object is handled using a function template parameter, see the <a class="link" href="../boost_functional_overloadedfunction/Tutorial.html" title="Tutorial">Tutorial</a> section).</p>
<p>The maximum number of functions to overload is given by the <code class="computeroutput"><code class="computeroutput"><a class="link" href="../BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX.html" title="Macro BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX">BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX</a></code></code> configuration macro.</p> <p>The maximum number of functions to overload is given by the <code class="computeroutput"><code class="computeroutput"><a class="link" href="../BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX.html" title="Macro BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX">BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX</a></code></code> configuration macro.</p>

View File

@ -35,19 +35,19 @@
<span class="keyword">class</span> <a class="link" href="overloaded_function.html" title="Class template overloaded_function">overloaded_function</a> <span class="special">{</span> <span class="keyword">class</span> <a class="link" href="overloaded_function.html" title="Class template overloaded_function">overloaded_function</a> <span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span> <span class="keyword">public</span><span class="special">:</span>
<span class="comment">// <a class="link" href="overloaded_function.html#boost.overloaded_functionconstruct-copy-destruct">construct/copy/destruct</a></span> <span class="comment">// <a class="link" href="overloaded_function.html#boost.overloaded_functionconstruct-copy-destruct">construct/copy/destruct</a></span>
<a class="link" href="overloaded_function.html#id294124-bb"><span class="identifier">overloaded_function</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">,</span> <a class="link" href="overloaded_function.html#id299641-bb"><span class="identifier">overloaded_function</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">,</span>
<span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">,</span> <span class="special">...</span><span class="special">)</span><span class="special">;</span> <span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">,</span> <span class="special">...</span><span class="special">)</span><span class="special">;</span>
<span class="comment">// <a class="link" href="overloaded_function.html#id294054-bb">public member functions</a></span> <span class="comment">// <a class="link" href="overloaded_function.html#id299571-bb">public member functions</a></span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">result_type</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">result_type</span>
<a class="link" href="overloaded_function.html#id294056-bb"><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span></a><span class="special">(</span><span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg1_type</span><span class="special">,</span> <a class="link" href="overloaded_function.html#id299574-bb"><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span></a><span class="special">(</span><span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg1_type</span><span class="special">,</span>
<span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg2_type</span><span class="special">,</span> <span class="special">...</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> <span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg2_type</span><span class="special">,</span> <span class="special">...</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">result_type</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">result_type</span>
<a class="link" href="overloaded_function.html#id294083-bb"><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span></a><span class="special">(</span><span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg1_type</span><span class="special">,</span> <a class="link" href="overloaded_function.html#id299600-bb"><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span></a><span class="special">(</span><span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg1_type</span><span class="special">,</span>
<span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg2_type</span><span class="special">,</span> <span class="special">...</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> <span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg2_type</span><span class="special">,</span> <span class="special">...</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div> <span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1"> <div class="refsect1">
<a name="id832217"></a><h2>Description</h2> <a name="id870004"></a><h2>Description</h2>
<p>This function object aggregates together calls to functions of all the specified function types <code class="computeroutput">F1</code>, <code class="computeroutput">F2</code>, etc. The specified function types must have distinct parameters from one another and they must be in the following format (which is the Boost.Function preferred syntax): </p> <p>This function object aggregates together calls to functions of all the specified function types <code class="computeroutput">F1</code>, <code class="computeroutput">F2</code>, etc. The specified function types must have distinct parameters from one another and they must be in the following format (which is the Boost.Function preferred syntax): </p>
<pre class="programlisting"> <span class="identifier">result_type</span> <span class="special">(</span><span class="identifier">argument1_type</span><span class="special">,</span> <span class="identifier">argumgnet2_type</span><span class="special">,</span> <span class="special">...</span><span class="special">)</span> <pre class="programlisting"> <span class="identifier">result_type</span> <span class="special">(</span><span class="identifier">argument1_type</span><span class="special">,</span> <span class="identifier">argumgnet2_type</span><span class="special">,</span> <span class="special">...</span><span class="special">)</span>
</pre> </pre>
@ -55,27 +55,27 @@
<p>The maximum number of functions to overload is given by the <code class="computeroutput"><a class="link" href="../BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX.html" title="Macro BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX">BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX</a></code> configuration macro. The maximum number of function parameters for each of the specified function types is given by the <code class="computeroutput"><a class="link" href="../BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX.html" title="Macro BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX">BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX</a></code> configuration macro.</p> <p>The maximum number of functions to overload is given by the <code class="computeroutput"><a class="link" href="../BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX.html" title="Macro BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX">BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX</a></code> configuration macro. The maximum number of function parameters for each of the specified function types is given by the <code class="computeroutput"><a class="link" href="../BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX.html" title="Macro BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX">BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX</a></code> configuration macro.</p>
<p><span class="bold"><strong>See:</strong></span> <a class="link" href="../boost_functional_overloadedfunction/Tutorial.html" title="Tutorial">Tutorial</a> section, <code class="computeroutput"><a class="link" href="make_overloaded_function.html" title="Function template make_overloaded_function">make_overloaded_function</a></code>, <code class="computeroutput"><a class="link" href="../BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX.html" title="Macro BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX">BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX</a></code>, <code class="computeroutput"><a class="link" href="../BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX.html" title="Macro BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX">BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX</a></code>, Boost.Function. </p> <p><span class="bold"><strong>See:</strong></span> <a class="link" href="../boost_functional_overloadedfunction/Tutorial.html" title="Tutorial">Tutorial</a> section, <code class="computeroutput"><a class="link" href="make_overloaded_function.html" title="Function template make_overloaded_function">make_overloaded_function</a></code>, <code class="computeroutput"><a class="link" href="../BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX.html" title="Macro BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX">BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_OVERLOAD_MAX</a></code>, <code class="computeroutput"><a class="link" href="../BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX.html" title="Macro BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX">BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX</a></code>, Boost.Function. </p>
<div class="refsect2"> <div class="refsect2">
<a name="id832337"></a><h3> <a name="id871216"></a><h3>
<a name="boost.overloaded_functionconstruct-copy-destruct"></a><code class="computeroutput">overloaded_function</code> <a name="boost.overloaded_functionconstruct-copy-destruct"></a><code class="computeroutput">overloaded_function</code>
public public
construct/copy/destruct</h3> construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"> <div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
<pre class="literallayout"><a name="id294124-bb"></a><span class="identifier">overloaded_function</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">,</span> <pre class="literallayout"><a name="id299641-bb"></a><span class="identifier">overloaded_function</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">,</span>
<span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">,</span> <span class="special">...</span><span class="special">)</span><span class="special">;</span></pre>Construct the overloaded function object. <p>Any function pointer, function reference, and monomorphic function object that can be converted to a <code class="computeroutput">boost::function</code> function object can be specified as parameter. </p> <span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">,</span> <span class="special">...</span><span class="special">)</span><span class="special">;</span></pre>Construct the overloaded function object. <p>Any function pointer, function reference, and monomorphic function object that can be converted to a <code class="computeroutput">boost::function</code> function object can be specified as parameter. </p>
</li></ol></div> </li></ol></div>
</div> </div>
<div class="refsect2"> <div class="refsect2">
<a name="id832462"></a><h3> <a name="id871341"></a><h3>
<a name="id294054-bb"></a><code class="computeroutput">overloaded_function</code> public member functions</h3> <a name="id299571-bb"></a><code class="computeroutput">overloaded_function</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1"> <div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem"> <li class="listitem">
<pre class="literallayout"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">result_type</span> <pre class="literallayout"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">result_type</span>
<a name="id294056-bb"></a><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span><span class="special">(</span><span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg1_type</span><span class="special">,</span> <a name="id299574-bb"></a><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span><span class="special">(</span><span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg1_type</span><span class="special">,</span>
<span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg2_type</span><span class="special">,</span> <span class="special">...</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Call operator matching the signature of the function type specified as 1st template parameter. <p>This will in turn invoke the call operator of the 1st function passed to the constructor. </p> <span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F1</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg2_type</span><span class="special">,</span> <span class="special">...</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Call operator matching the signature of the function type specified as 1st template parameter. <p>This will in turn invoke the call operator of the 1st function passed to the constructor. </p>
</li> </li>
<li class="listitem"> <li class="listitem">
<pre class="literallayout"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">result_type</span> <pre class="literallayout"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">result_type</span>
<a name="id294083-bb"></a><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span><span class="special">(</span><span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg1_type</span><span class="special">,</span> <a name="id299600-bb"></a><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span><span class="special">(</span><span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg1_type</span><span class="special">,</span>
<span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg2_type</span><span class="special">,</span> <span class="special">...</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Call operator matching the signature of the function type specified as 2nd template parameter. <p>This will in turn invoke the call operator of the 2nd function passed to the constructor.</p> <span class="keyword">typename</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function_traits</span><span class="special">&lt;</span> <span class="identifier">F2</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">arg2_type</span><span class="special">,</span> <span class="special">...</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>Call operator matching the signature of the function type specified as 2nd template parameter. <p>This will in turn invoke the call operator of the 2nd function passed to the constructor.</p>
<p><span class="bold"><strong>Note:</strong></span> Similar call operators are present for all specified function types <code class="computeroutput">F1</code>, <code class="computeroutput">F2</code>, etc (even if not exhaustively listed by this documentation). </p> <p><span class="bold"><strong>Note:</strong></span> Similar call operators are present for all specified function types <code class="computeroutput">F1</code>, <code class="computeroutput">F2</code>, etc (even if not exhaustively listed by this documentation). </p>
</li> </li>

View File

@ -41,9 +41,22 @@
and Platforms</a> and Platforms</a>
</h3></div></div></div> </h3></div></div></div>
<p> <p>
The library was tested by the authors on GCC 4.5.3 (with and without C++11 The authors originally developed and tested the library on:
features <code class="literal">-std=c++0x</code>) and MSVC 8.0 under Linux, Cygwin, </p>
and Windows 7. <div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
GNU Compiler Collection (GCC) C++ 4.5.3 (with and without C++11 features
enabled <code class="computeroutput"><span class="special">-</span><span class="identifier">std</span><span class="special">=</span><span class="identifier">c</span><span class="special">++</span><span class="number">0</span><span class="identifier">x</span></code>)
on Cygwin.
</li>
<li class="listitem">
Miscrosoft Visual C++ (MSVC) 8.0 on Windows 7.
</li>
</ol></div>
<p>
See the library <a href="http://www.boost.org/development/tests/release/developer/functional-overloaded_function.html" target="_top">regressions
test results</a> for detailed information on supported compilers and
platforms.
</p> </p>
</div> </div>
<div class="section boost_functional_overloadedfunction_Getting_Started_installation"> <div class="section boost_functional_overloadedfunction_Getting_Started_installation">

View File

@ -42,23 +42,15 @@
Consider the following functions with distinct signatures: Consider the following functions with distinct signatures:
</p> </p>
<p> <p>
</p> [identity_decls]
<pre class="programlisting"><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&amp;</span> <span class="identifier">identity_s</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&amp;</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">x</span><span class="special">;</span> <span class="special">}</span> <span class="comment">// As pointer.</span>
<span class="keyword">int</span> <span class="identifier">identity_i_impl</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">x</span><span class="special">;</span> <span class="special">}</span>
<span class="keyword">int</span> <span class="special">(&amp;</span><span class="identifier">identity_i</span><span class="special">)(</span><span class="keyword">int</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">identity_i_impl</span><span class="special">;</span> <span class="comment">// Function reference.</span>
<span class="keyword">double</span> <span class="identifier">identity_d_impl</span><span class="special">(</span><span class="keyword">double</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">x</span><span class="special">;</span> <span class="special">}</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span><span class="keyword">double</span> <span class="special">(</span><span class="keyword">double</span><span class="special">)&gt;</span> <span class="identifier">identity_d</span> <span class="special">=</span> <span class="identifier">identity_d_impl</span><span class="special">;</span> <span class="comment">// Functor.</span>
</pre>
<p>
</p> </p>
<p> <p>
This library header <code class="computeroutput"><a class="link" href="../reference.html#header.boost.functional.overloaded_function_hpp" title="Header &lt;boost/functional/overloaded_function.hpp&gt;">boost/functional/overloaded_function.hpp</a></code> This library header <code class="computeroutput"><a class="link" href="../reference.html#header.boost.functional.overloaded_function_hpp" title="Header &lt;boost/functional/overloaded_function.hpp&gt;">boost/functional/overloaded_function.hpp</a></code>
provides a <code class="computeroutput"><a class="link" href="../boost/overloaded_function.html" title="Class template overloaded_function">boost::overloaded_function</a></code> provides a <code class="computeroutput"><a class="link" href="../boost/overloaded_function.html" title="Class template overloaded_function">boost::overloaded_function</a></code>
class template that creates a single overloaded function object that can class template that creates a single overloaded function object that can
be used to call the specified functions instead of using the separate function be used to call the specified functions instead of using the separate function
names (see also <a href="../../../test/identity.cpp" target="_top"><code class="literal">identity.cpp</code></a>): names (see also <a href="../../../test/functor.cpp" target="_top"><code class="literal">functor.cpp</code></a>
and <a href="../../../test/identity.hpp" target="_top"><code class="literal">identity.hpp</code></a>):
</p> </p>
<p> <p>
</p> </p>
@ -114,7 +106,8 @@
<p> <p>
The <code class="computeroutput"><a class="link" href="../boost/make_overloaded_function.html" title="Function template make_overloaded_function">boost::make_overloaded_function</a></code> The <code class="computeroutput"><a class="link" href="../boost/make_overloaded_function.html" title="Function template make_overloaded_function">boost::make_overloaded_function</a></code>
function template can be useful when used together with <a href="http://www.boost.org/doc/libs/typeof" target="_top">Boost.Typeof</a>'s function template can be useful when used together with <a href="http://www.boost.org/doc/libs/typeof" target="_top">Boost.Typeof</a>'s
<code class="computeroutput"><span class="identifier">BOOST_AUTO</span></code> (or C++11 <code class="computeroutput"><span class="keyword">auto</span></code>). For example (see also <a href="../../../test/identity.cpp" target="_top"><code class="literal">identity.cpp</code></a>): <code class="computeroutput"><span class="identifier">BOOST_AUTO</span></code> (or C++11 <code class="computeroutput"><span class="keyword">auto</span></code>). For example (see also <a href="../../../test/make_decl.cpp" target="_top"><code class="literal">make_decl.cpp</code></a>
and <a href="../../../test/identity.hpp" target="_top"><code class="literal">identity.hpp</code></a>):
</p> </p>
<p> <p>
</p> </p>
@ -143,7 +136,8 @@
Another case where <code class="computeroutput"><a class="link" href="../boost/make_overloaded_function.html" title="Function template make_overloaded_function">boost::make_overloaded_function</a></code> Another case where <code class="computeroutput"><a class="link" href="../boost/make_overloaded_function.html" title="Function template make_overloaded_function">boost::make_overloaded_function</a></code>
can be useful is when the overloaded function object is passed to a function can be useful is when the overloaded function object is passed to a function
template which can hide the specific <code class="computeroutput"><a class="link" href="../boost/overloaded_function.html" title="Class template overloaded_function">boost::overloaded_function</a></code> template which can hide the specific <code class="computeroutput"><a class="link" href="../boost/overloaded_function.html" title="Class template overloaded_function">boost::overloaded_function</a></code>
type using a template parameter. For example (see also <a href="../../../test/identity.cpp" target="_top"><code class="literal">identity.cpp</code></a>): type using a template parameter. For example (see also <a href="../../../test/make_call.cpp" target="_top"><code class="literal">make_call.cpp</code></a>
and <a href="../../../test/identity.hpp" target="_top"><code class="literal">identity.hpp</code></a>):
</p> </p>
<p> <p>
</p> </p>

View File

@ -69,16 +69,7 @@
Consider the following functions with distinct signatures: Consider the following functions with distinct signatures:
</p> </p>
<p> <p>
</p> [identity_decls]
<pre class="programlisting"><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&amp;</span> <span class="identifier">identity_s</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&amp;</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">x</span><span class="special">;</span> <span class="special">}</span> <span class="comment">// As pointer.</span>
<span class="keyword">int</span> <span class="identifier">identity_i_impl</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">x</span><span class="special">;</span> <span class="special">}</span>
<span class="keyword">int</span> <span class="special">(&amp;</span><span class="identifier">identity_i</span><span class="special">)(</span><span class="keyword">int</span><span class="special">)</span> <span class="special">=</span> <span class="identifier">identity_i_impl</span><span class="special">;</span> <span class="comment">// Function reference.</span>
<span class="keyword">double</span> <span class="identifier">identity_d_impl</span><span class="special">(</span><span class="keyword">double</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">x</span><span class="special">;</span> <span class="special">}</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span><span class="keyword">double</span> <span class="special">(</span><span class="keyword">double</span><span class="special">)&gt;</span> <span class="identifier">identity_d</span> <span class="special">=</span> <span class="identifier">identity_d_impl</span><span class="special">;</span> <span class="comment">// Functor.</span>
</pre>
<p>
</p> </p>
<p> <p>
Instead of calling them using their separate names (here <code class="computeroutput"><span class="identifier">BOOST_CHECK</span></code> Instead of calling them using their separate names (here <code class="computeroutput"><span class="identifier">BOOST_CHECK</span></code>
@ -97,7 +88,8 @@
It is possible to use this library to create a single <a href="http://en.wikipedia.org/wiki/Function_overloading" target="_top">overloaded</a> It is possible to use this library to create a single <a href="http://en.wikipedia.org/wiki/Function_overloading" target="_top">overloaded</a>
function object (or <a href="http://en.wikipedia.org/wiki/Functor" target="_top">functor</a>) function object (or <a href="http://en.wikipedia.org/wiki/Functor" target="_top">functor</a>)
named <code class="computeroutput"><span class="identifier">identity</span></code> that aggregates named <code class="computeroutput"><span class="identifier">identity</span></code> that aggregates
together the calls to the specific functions (see also <a href="../../test/identity.cpp" target="_top"><code class="literal">identity.cpp</code></a>): together the calls to the specific functions (see also <a href="../../test/functor.cpp" target="_top"><code class="literal">functor.cpp</code></a>
and <a href="../../test/identity.hpp" target="_top"><code class="literal">identity.hpp</code></a>):
</p> </p>
<p> <p>
</p> </p>
@ -133,7 +125,7 @@
</div> </div>
</div> </div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"><p><small>Last revised: February 20, 2012 at 20:10:59 GMT</small></p></td> <td align="left"><p><small>Last revised: March 22, 2012 at 20:51:03 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td> <td align="right"><div class="copyright-footer"></div></td>
</tr></table> </tr></table>
<hr> <hr>

View File

@ -27,7 +27,9 @@
[def __Boost_Function__ [@http://www.boost.org/libs/function Boost.Function]] [def __Boost_Function__ [@http://www.boost.org/libs/function Boost.Function]]
[def __Boost_Typeof__ [@http://www.boost.org/doc/libs/typeof Boost.Typeof]] [def __Boost_Typeof__ [@http://www.boost.org/doc/libs/typeof Boost.Typeof]]
[import ../test/identity.cpp] [import ../test/functor.cpp]
[import ../test/make_decl.cpp]
[import ../test/make_call.cpp]
This library allows to overload different functions into a single function object. This library allows to overload different functions into a single function object.
@ -45,9 +47,9 @@ The examples of this documentation are executed as part of the library test suit
[identity_calls] [identity_calls]
It is possible to use this library to create a single [@http://en.wikipedia.org/wiki/Function_overloading overloaded] function object (or [@http://en.wikipedia.org/wiki/Functor functor]) named `identity` that aggregates together the calls to the specific functions (see also [@../../test/identity.cpp =identity.cpp=]): It is possible to use this library to create a single [@http://en.wikipedia.org/wiki/Function_overloading overloaded] function object (or [@http://en.wikipedia.org/wiki/Functor functor]) named `identity` that aggregates together the calls to the specific functions (see also [@../../test/functor.cpp =functor.cpp=] and [@../../test/identity.hpp =identity.hpp=]):
[identity] [identity_functor]
Note how the functions are called via a single overloaded function object `identity` instead of using their different names `identity_s`, `identity_i`, and `identity_d`. Note how the functions are called via a single overloaded function object `identity` instead of using their different names `identity_s`, `identity_i`, and `identity_d`.
@ -59,7 +61,12 @@ This section explains how to setup a system to use this library.
[section Compilers and Platforms] [section Compilers and Platforms]
The library was tested by the authors on GCC 4.5.3 (with and without C++11 features [^-std=c++0x]) and MSVC 8.0 under Linux, Cygwin, and Windows 7. The authors originally developed and tested the library on:
# GNU Compiler Collection (GCC) C++ 4.5.3 (with and without C++11 features enabled `-std=c++0x`) on Cygwin.
# Miscrosoft Visual C++ (MSVC) 8.0 on Windows 7.
See the library [@http://www.boost.org/development/tests/release/developer/functional-overloaded_function.html regressions test results] for detailed information on supported compilers and platforms.
[endsect] [endsect]
@ -87,9 +94,9 @@ Consider the following functions with distinct signatures:
[identity_decls] [identity_decls]
This library header [headerref boost/functional/overloaded_function.hpp] provides a [classref boost::overloaded_function] class template that creates a single overloaded function object that can be used to call the specified functions instead of using the separate function names (see also [@../../test/identity.cpp =identity.cpp=]): This library header [headerref boost/functional/overloaded_function.hpp] provides a [classref boost::overloaded_function] class template that creates a single overloaded function object that can be used to call the specified functions instead of using the separate function names (see also [@../../test/functor.cpp =functor.cpp=] and [@../../test/identity.hpp =identity.hpp=]):
[identity] [identity_functor]
Note how function types in the following format are passed as template parameters to [classref boost::overloaded_function] (this is the format of __Boost_Function__'s preferred syntax): Note how function types in the following format are passed as template parameters to [classref boost::overloaded_function] (this is the format of __Boost_Function__'s preferred syntax):
@ -119,7 +126,7 @@ For convenience, this library also provides the [funcref boost::make_overloaded_
The function types are automatically deduced from the specified functions and the appropriate [classref boost::overloaded_function] instantiation is returned by [funcref boost::make_overloaded_function]. The function types are automatically deduced from the specified functions and the appropriate [classref boost::overloaded_function] instantiation is returned by [funcref boost::make_overloaded_function].
The [funcref boost::make_overloaded_function] function template can be useful when used together with __Boost_Typeof__'s `BOOST_AUTO` (or C++11 `auto`). The [funcref boost::make_overloaded_function] function template can be useful when used together with __Boost_Typeof__'s `BOOST_AUTO` (or C++11 `auto`).
For example (see also [@../../test/identity.cpp =identity.cpp=]): For example (see also [@../../test/make_decl.cpp =make_decl.cpp=] and [@../../test/identity.hpp =identity.hpp=]):
[identity_make] [identity_make]
@ -127,7 +134,7 @@ Note how the overloaded function object `identity` has been created specifying o
Therefore, [funcref boost::make_overloaded_function] provides a more concise syntax in this context when compared with [classref boost::overloaded_function]. Therefore, [funcref boost::make_overloaded_function] provides a more concise syntax in this context when compared with [classref boost::overloaded_function].
Another case where [funcref boost::make_overloaded_function] can be useful is when the overloaded function object is passed to a function template which can hide the specific [classref boost::overloaded_function] type using a template parameter. Another case where [funcref boost::make_overloaded_function] can be useful is when the overloaded function object is passed to a function template which can hide the specific [classref boost::overloaded_function] type using a template parameter.
For example (see also [@../../test/identity.cpp =identity.cpp=]): For example (see also [@../../test/make_call.cpp =make_call.cpp=] and [@../../test/identity.hpp =identity.hpp=]):
[identity_make_checks] [identity_make_checks]
[identity_make_call] [identity_make_call]

View File

@ -9,5 +9,7 @@ import testing ;
project : requirements <library>/boost//unit_test_framework ; project : requirements <library>/boost//unit_test_framework ;
run identity.cpp ; run functor.cpp ;
run make_decl.cpp ;
run make_call.cpp ;

View File

@ -0,0 +1,33 @@
// Copyright (C) 2009-2012 Lorenzo Caminiti
// Distributed under the Boost Software License, Version 1.0
// (see accompanying file LICENSE_1_0.txt or a copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Home at http://www.boost.org/libs/functional/overloaded_function
#include "identity.hpp"
#include <boost/functional/overloaded_function.hpp>
#define BOOST_TEST_MODULE TestFunctor
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_CASE(test_functor) {
//[identity_calls
BOOST_CHECK(identity_s("abc") == "abc");
BOOST_CHECK(identity_i(123) == 123);
BOOST_CHECK(identity_d(1.23) == 1.23);
//]
//[identity_functor
boost::overloaded_function<
const std::string& (const std::string&)
, int (int)
, double (double)
> identity(identity_s, identity_i, identity_d);
// All calls via single `identity` function.
BOOST_CHECK(identity("abc") == "abc");
BOOST_CHECK(identity(123) == 123);
BOOST_CHECK(identity(1.23) == 1.23);
//]
}

View File

@ -1,70 +0,0 @@
// Copyright (C) 2009-2012 Lorenzo Caminiti
// Distributed under the Boost Software License, Version 1.0
// (see accompanying file LICENSE_1_0.txt or a copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Home at http://www.boost.org/libs/functional/overloaded_function
#include <boost/functional/overloaded_function.hpp>
#include <boost/function.hpp>
#define BOOST_TEST_MODULE TestIdentity
#include <boost/test/unit_test.hpp>
#include <string>
//[identity_make_checks
template<typename F>
void check(F identity) {
BOOST_CHECK(identity("abc") == "abc");
BOOST_CHECK(identity(123) == 123);
BOOST_CHECK(identity(1.23) == 1.23);
}
//]
//[identity_decls
const std::string& identity_s(const std::string& x) { return x; } // As pointer.
int identity_i_impl(int x) { return x; }
int (&identity_i)(int) = identity_i_impl; // Function reference.
double identity_d_impl(double x) { return x; }
boost::function<double (double)> identity_d = identity_d_impl; // Functor.
//]
BOOST_AUTO_TEST_CASE(test_identity) {
//[identity_calls
BOOST_CHECK(identity_s("abc") == "abc");
BOOST_CHECK(identity_i(123) == 123);
BOOST_CHECK(identity_d(1.23) == 1.23);
//]
{
//[identity
boost::overloaded_function<
const std::string& (const std::string&)
, int (int)
, double (double)
> identity(identity_s, identity_i, identity_d);
// All calls via single `identity` function.
BOOST_CHECK(identity("abc") == "abc");
BOOST_CHECK(identity(123) == 123);
BOOST_CHECK(identity(1.23) == 1.23);
//]
}
{
//[identity_make
BOOST_AUTO(identity, boost::make_overloaded_function(
identity_s, identity_i, identity_d));
BOOST_CHECK(identity("abc") == "abc");
BOOST_CHECK(identity(123) == 123);
BOOST_CHECK(identity(1.23) == 1.23);
//]
}
//[identity_make_call
check(boost::make_overloaded_function(identity_s, identity_i, identity_d));
//]
}

View File

@ -0,0 +1,25 @@
// Copyright (C) 2009-2012 Lorenzo Caminiti
// Distributed under the Boost Software License, Version 1.0
// (see accompanying file LICENSE_1_0.txt or a copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Home at http://www.boost.org/libs/functional/overloaded_function
#ifndef IDENTITY_HPP_
#define IDENTITY_HPP_
#include <boost/function.hpp>
#include <string>
//[identity_decls
const std::string& identity_s(const std::string& x) { return x; } // As pointer.
int identity_i_impl(int x) { return x; }
int (&identity_i)(int) = identity_i_impl; // Function reference.
double identity_d_impl(double x) { return x; }
boost::function<double (double)> identity_d = identity_d_impl; // Functor.
//]
#endif // #include guard

View File

@ -0,0 +1,27 @@
// Copyright (C) 2009-2012 Lorenzo Caminiti
// Distributed under the Boost Software License, Version 1.0
// (see accompanying file LICENSE_1_0.txt or a copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Home at http://www.boost.org/libs/functional/overloaded_function
#include "identity.hpp"
#include <boost/functional/overloaded_function.hpp>
#define BOOST_TEST_MODULE TestMakeCall
#include <boost/test/unit_test.hpp>
//[identity_make_checks
template<typename F>
void check(F identity) {
BOOST_CHECK(identity("abc") == "abc");
BOOST_CHECK(identity(123) == 123);
BOOST_CHECK(identity(1.23) == 1.23);
}
//]
BOOST_AUTO_TEST_CASE(test_identity) {
//[identity_make_call
check(boost::make_overloaded_function(identity_s, identity_i, identity_d));
//]
}

View File

@ -0,0 +1,23 @@
// Copyright (C) 2009-2012 Lorenzo Caminiti
// Distributed under the Boost Software License, Version 1.0
// (see accompanying file LICENSE_1_0.txt or a copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Home at http://www.boost.org/libs/functional/overloaded_function
#include "identity.hpp"
#include <boost/functional/overloaded_function.hpp>
#define BOOST_TEST_MODULE TestMakeDecl
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_CASE(test_make_decl) {
//[identity_make
BOOST_AUTO(identity, boost::make_overloaded_function(
identity_s, identity_i, identity_d));
BOOST_CHECK(identity("abc") == "abc");
BOOST_CHECK(identity(123) == 123);
BOOST_CHECK(identity(1.23) == 1.23);
//]
}