title: Boost MPL: Call a (member) function only if it exists
body: <p>I have a class A that has a template parameter T. There are use cases where the class T offers a function func1() and there are use cases where T doesn't offer it.
  A function f() in A should call func1(), iff it exists. I think this should be possible with boost mpl, but I don't know how.
  Here some pseudo code:</p>
  
  <pre><code>template&lt;class T&gt;
  class A
  {
      void f(T param)
      {
          if(T::func1 is an existing function)
              param.func1();
      }
  };
  </code></pre>
  
  <p>Even better would be an else-case:</p>
  
  <pre><code>template&lt;class T&gt;
  class A
  {
      void f(T param)
      {
          if(T::func1 is an existing function)
              param.func1();
          else
              cout &lt;&lt; "func1 doesn't exist" &lt;&lt; endl;
      }
  };
  </code></pre>