What is the most efficient way to pass a non generic function? : <p>I am learning functional programming in C++. My intention is to pass a non generic function as argument. I know about the template method, however I would like to restrict the function signature as part of the API design. I worked out 4 different methods <a href="http://cpp.sh/2wds" rel="noreferrer">example on cpp.sh</a>:</p>

<pre><code>// Example program
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;functional&gt;

typedef int(functor_type)(int);


int by_forwarding(functor_type &amp;&amp;x)  {
    return x(1);
}

int functor_by_value(functor_type x) {
    return x(1);
}

int std_func_by_value(std::function&lt;functor_type&gt; x) {
    return x(1);
}

int std_func_by_forwarding(std::function&lt;functor_type&gt; &amp;&amp;x) {
    return x(1);
}

int main()
{
    std::cout &lt;&lt; functor_by_value([](int a){return a;}); // works
    std::cout &lt;&lt; std_func_by_value([](int a){return a;}); // works
    std::cout &lt;&lt; std_func_by_forwarding(std::move([](int a){return a;})); // works

    //std::cout &lt;&lt; by_forwarding([](int a){return a;}); // how to move lambda with forwarding ?
}
</code></pre>

<p>Is any of the above attempts correct? If not, how do i achieve my goal?</p>
