title: Template Specialization Function with Eigen arguments
body: <p>I am trying to write some functions with template specialization for Eigen types, following this question: <a href="https://stackoverflow.com/questions/22725867/eigen-type-deduction-in-template-specialization-of-base-class">Eigen: type deduction in template specialization of base-class</a></p>
  
  <p>I wrote this:</p>
  
  <pre><code>#include &lt;type_traits&gt;
  #include &lt;Eigen/Core&gt;
  
  namespace isEigenPlainObjectBaseDetail {
      template &lt;typename T&gt;
      std::true_type test(const Eigen::PlainObjectBase&lt;T&gt;);
      std::false_type test(...);
  }
  template &lt;typename T&gt;
  struct isEigenPlainObjectBase :
          public decltype(isEigenPlainObjectBaseDetail::test(std::declval&lt;T&gt;())) {};
  
  template &lt;typename T, typename Enable = void&gt;
  void foo(T&amp; obj) {
      std::cout &lt;&lt; "Generic Called!\n";
  }
  
  template &lt;typename T, typename std::enable_if&lt;isEigenPlainObjectBase&lt;T&gt;::value&gt;::type&gt;
  void foo(T&amp; obj) {
      std::cout &lt;&lt; "Eigen Specialization Called!";
  }
  
  int main() {
      Eigen::MatrixXd m;
      Eigen::VectorXd v;
      int i = 0;
      foo(i);
      foo(m);
      foo(v);
      return 0;
  }
  </code></pre>
  
  <p>but this calls everytime the generic function:</p>
  
  <pre><code>Generic Called!
  Generic Called!
  Generic Called!
  </code></pre>
  
  <p>What am I doing wrong? How can I write template specializations for functions with Eigen matrices and vectors?</p>