How to call conditionally B::f only if derived from B in C++11? : <p>In case when static polymorphism is used, especially in templates (e.g. with policy/strategy pattern), it may be required to call base function member, but you don't know was instantiated class actually derived from this base or not.</p>

<p>This easily can be solved with old good C++ ellipsis overload trick:</p>

<pre><code>#include &lt;iostream&gt;

template &lt;class I&gt;
struct if_derived_from
{
    template &lt;void (I::*f)()&gt;
    static void call(I&amp; x) {  (x.*f)(); }

    static void call(...) { }
};

struct A    { void reset() { std::cout &lt;&lt; "reset A" &lt;&lt; std::endl; } };
struct B    { void reset() { std::cout &lt;&lt; "reset B" &lt;&lt; std::endl; } };
struct C    { void reset() { std::cout &lt;&lt; "reset C" &lt;&lt; std::endl; } };
struct E: C { void reset() { std::cout &lt;&lt; "reset E" &lt;&lt; std::endl; } };
struct D: E {};

struct X: A, D {};

int main()
{
    X x;
    if_derived_from&lt;A&gt;::call&lt;&amp;A::reset&gt;(x);
    if_derived_from&lt;B&gt;::call&lt;&amp;B::reset&gt;(x);
    if_derived_from&lt;C&gt;::call&lt;&amp;C::reset&gt;(x);
    if_derived_from&lt;E&gt;::call&lt;&amp;E::reset&gt;(x);
    return 0;
}
</code></pre>

<p>The question is:</p>

<ul>
<li>Is there any better <em>simple</em> way (e.g. SFINAE doesn't look so) to achieve same result in C++11/C++14?</li>
<li>Would empty call of ellipsis parameter function be elided by optimizing compiler? Hope such case is not special against any "normal" function.</li>
</ul>
