title: How to SFINAE out non-containers parameters
body: <p>I have a template function that I want to enable only for standard containers (or containers compatible with standard containers, which at least provide a <code>begin()</code> member function). I'm SFINAE-ing out non-containers in the following way:</p>
  
  <pre><code>template&lt;typename Container&gt;
  typename Container::value_type 
  f(const Container&amp; c,
      typename std::enable_if&lt;
          std::is_same&lt;
              decltype(*c.begin()),
              typename Container::value_type
          &gt;::value
      &gt;::type* = nullptr)
  {
      // implementation here
  }
  </code></pre>
  
  <p>The <code>std::is_same</code> and <code>decltype</code> don't look too elegant. Is there any better way of doing this?</p>
  
  <p>PS: I need the SFINAE here because I have a different overload</p>
  
  <pre><code>template&lt;typename Derived&gt;
  f(const Eigen::MatrixBase&lt;Derived&gt;&amp; A)
  </code></pre>
  
  <p>and whenever I try <code>f(some_Eigen_matrix)</code>, the <code>Container</code> overload ends up being picked up, then the compiler spits out an error because the type is lacking <code>begin()</code>.</p>