Boost C++ Libraries: Ticket #13114: Multiple signatures for function https://svn.boost.org/trac10/ticket/13114 <p> I am not familiar with boost, just wanted to suggest the possibility of having <code>function</code> take multiple signatures </p> <div class="wiki-code"><div class="code"><pre><span class="n">function</span><span class="o">&lt;</span><span class="kt">void</span> <span class="p">(</span><span class="kt">int</span><span class="p">),</span> <span class="kt">int</span> <span class="p">(</span><span class="kt">double</span><span class="p">)</span><span class="o">&gt;</span> <span class="n">f</span><span class="p">;</span> </pre></div></div><p> This is compatible with <code>std::function</code>, but unknown feasibility for <code>boost::function</code> in its current form. </p> <p> The key idea is to recursively implement <code>operator()</code> from the argument list </p> <div class="wiki-code"><div class="code"><pre><span class="k">template</span><span class="o">&lt;</span><span class="k">typename</span> <span class="n">Ret</span><span class="p">,</span> <span class="k">typename</span><span class="p">...</span> <span class="n">Args</span><span class="p">,</span> <span class="k">typename</span><span class="p">...</span> <span class="n">Fns</span><span class="o">&gt;</span> <span class="k">struct</span> <span class="n">erasure_base</span><span class="o">&lt;</span><span class="n">Ret</span> <span class="p">(</span><span class="n">Args</span><span class="p">...),</span> <span class="n">Fns</span><span class="p">...</span><span class="o">&gt;</span> <span class="o">:</span> <span class="n">erasure_base</span><span class="o">&lt;</span><span class="n">Fns</span><span class="p">...</span><span class="o">&gt;</span> <span class="p">{</span> <span class="k">virtual</span> <span class="n">Ret</span> <span class="k">operator</span><span class="p">()(</span><span class="n">Args</span><span class="o">&amp;&amp;</span><span class="p">...)</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="k">using</span> <span class="n">erasure_base</span><span class="o">&lt;</span><span class="n">Fns</span><span class="p">...</span><span class="o">&gt;::</span><span class="k">operator</span><span class="p">();</span> <span class="p">};</span> </pre></div></div><p> Attached file is a proof-of-concept implementation of such functionality. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13114 Trac 1.4.3 stinkingmadgod@… Mon, 10 Jul 2017 18:10:31 GMT attachment set https://svn.boost.org/trac10/ticket/13114 https://svn.boost.org/trac10/ticket/13114 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">function.hpp</span> </li> </ul> <p> Proof-of-concept for function taking multiple signatures </p> Ticket