1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html> 3<head> 4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 5<title>Function call</title> 6<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css"> 7<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 8<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> 9<link rel="up" href="../../boost_typeerasure/reference.html#header.boost.type_erasure.call_hpp" title="Header <boost/type_erasure/call.hpp>"> 10<link rel="prev" href="typeid_.html" title="Struct template typeid_"> 11<link rel="next" href="callable.html" title="Struct template callable"> 12</head> 13<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 14<table cellpadding="2" width="100%"><tr> 15<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td> 16<td align="center"><a href="../../../../index.html">Home</a></td> 17<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td> 18<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 19<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 20<td align="center"><a href="../../../../more/index.htm">More</a></td> 21</tr></table> 22<hr> 23<div class="spirit-nav"> 24<a accesskey="p" href="typeid_.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../boost_typeerasure/reference.html#header.boost.type_erasure.call_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="callable.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 25</div> 26<div class="refentry"> 27<a name="boost.type_erasure.call"></a><div class="titlepage"></div> 28<div class="refnamediv"> 29<h2><span class="refentrytitle">Function call</span></h2> 30<p>boost::type_erasure::call</p> 31</div> 32<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2> 33<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: <<a class="link" href="../../boost_typeerasure/reference.html#header.boost.type_erasure.call_hpp" title="Header <boost/type_erasure/call.hpp>">boost/type_erasure/call.hpp</a>> 34 35</span> 36<span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> Concept<span class="special">,</span> <span class="keyword">typename</span> Op<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> U<span class="special">></span> 37 <span class="emphasis"><em><span class="identifier">unspecified</span></em></span> <span class="identifier">call</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="binding.html" title="Class template binding">binding</a><span class="special"><</span> <span class="identifier">Concept</span> <span class="special">></span> <span class="special">&</span> binding<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Op</span> <span class="special">&</span><span class="special">,</span> 38 <span class="identifier">U</span> <span class="special">&&</span><span class="special">...</span> args<span class="special">)</span><span class="special">;</span> 39<span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> Op<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> U<span class="special">></span> <span class="emphasis"><em><span class="identifier">unspecified</span></em></span> <span class="identifier">call</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">Op</span> <span class="special">&</span><span class="special">,</span> <span class="identifier">U</span> <span class="special">&&</span><span class="special">...</span> args<span class="special">)</span><span class="special">;</span></pre></div> 40<div class="refsect1"> 41<a name="id-1.3.41.13.7.3.4"></a><h2>Description</h2> 42<p>Dispatches a type erased function.</p> 43<p><code class="computeroutput">Op</code> must be a primitive concept which is present in <code class="computeroutput">Concept</code>. Its signature determines how the arguments of <code class="computeroutput"><a class="link" href="call.html" title="Function call">call</a></code> are handled. If the argument is a <code class="computeroutput"><a class="link" href="placeholder.html" title="Struct placeholder">placeholder</a></code>, <code class="computeroutput"><a class="link" href="call.html" title="Function call">call</a></code> expects an <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code> using that <code class="computeroutput"><a class="link" href="placeholder.html" title="Struct placeholder">placeholder</a></code>. This <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code> is unwrapped by <code class="computeroutput"><a class="link" href="call.html" title="Function call">call</a></code>. The type that it stores must be the same type specified by <code class="computeroutput">binding</code>. Any arguments that are not placeholders in the signature of <code class="computeroutput">Op</code> are passed through unchanged.</p> 44<p>If <code class="computeroutput">binding</code> is not specified, it will be deduced from the arguments. Naturally this requires at least one argument to be an <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code>. In this case, all <code class="computeroutput"><a class="link" href="any.html" title="Class template any">any</a></code> arguments must have the same <code class="computeroutput"><a class="link" href="binding.html" title="Class template binding">binding</a></code>.</p> 45<p> 46 47Example:</p> 48<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span> 49 <span class="identifier">copy_constructible</span><span class="special"><</span><span class="identifier">_b</span><span class="special">></span><span class="special">,</span> 50 <span class="identifier">addable</span><span class="special"><</span><span class="identifier">_a</span><span class="special">,</span> <span class="keyword">int</span><span class="special">,</span> <span class="identifier">_b</span><span class="special">></span> <span class="special">></span> <span class="identifier">concept</span><span class="special">;</span> 51<span class="identifier">any</span><span class="special"><</span><span class="identifier">concept</span><span class="special">,</span> <span class="identifier">_a</span><span class="special">></span> <span class="identifier">a</span> <span class="special">=</span> <span class="special">...</span><span class="special">;</span> 52<span class="identifier">any</span><span class="special"><</span><span class="identifier">concept</span><span class="special">,</span> <span class="identifier">_b</span><span class="special">></span> <span class="identifier">b</span><span class="special">(</span><span class="identifier">call</span><span class="special">(</span><span class="identifier">addable</span><span class="special"><</span><span class="identifier">_a</span><span class="special">,</span> <span class="keyword">int</span><span class="special">,</span> <span class="identifier">_b</span><span class="special">></span><span class="special">(</span><span class="special">)</span><span class="special">,</span> <span class="identifier">a</span><span class="special">,</span> <span class="number">10</span><span class="special">)</span><span class="special">)</span><span class="special">;</span> 53</pre> 54<p>The signature of <code class="computeroutput"><a class="link" href="addable.html" title="Struct template addable">addable</a></code> is <code class="computeroutput">_b(const _a&, const int&)</code> </p> 55<div class="variablelist"><table border="0" class="variablelist compact"> 56<colgroup> 57<col align="left" valign="top"> 58<col> 59</colgroup> 60<tbody> 61<tr> 62<td><p><span class="term">Returns:</span></p></td> 63<td><p>The result of the operation. If the result type of the signature of <code class="computeroutput">Op</code> is a placeholder, the result will be converted to the appropriate <a class="link" href="any.html" title="Class template any">any</a> type.</p></td> 64</tr> 65<tr> 66<td><p><span class="term">Throws:</span></p></td> 67<td> 68<a class="link" href="../bad_function_call.html" title="Class bad_function_call">bad_function_call</a> if <a class="link" href="relaxed.html" title="Struct relaxed">relaxed</a> is in <code class="computeroutput">Concept</code> and there is a type mismatch.</td> 69</tr> 70</tbody> 71</table></div> 72</div> 73</div> 74<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 75<td align="left"></td> 76<td align="right"><div class="copyright-footer">Copyright © 2011-2013 Steven Watanabe<p> 77 Distributed under the Boost Software License, Version 1.0. (See accompanying 78 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 79 </p> 80</div></td> 81</tr></table> 82<hr> 83<div class="spirit-nav"> 84<a accesskey="p" href="typeid_.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../boost_typeerasure/reference.html#header.boost.type_erasure.call_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="callable.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 85</div> 86</body> 87</html> 88