title: Disable temporary binding of Eigen expression to const references
body: <p>I am trying to write a function that accepts only lvalue Eigen expressions passed via <code>const</code> references. My first idea was to keep only the overload <code>const Eigen::MatrixBase&lt;Derived&gt;&amp;</code> and <code>delete</code> the <code>Eigen::MatrixBase&lt;Derived&gt;&amp;&amp;</code> one. To my surprise, the <code>delete</code>d function was not part of the overload candidate set. So I tried the code below</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;Eigen/Dense&gt;
  
  #define PRINT_MY_NAME std::cout &lt;&lt; __PRETTY_FUNCTION__ &lt;&lt; '\n'
  
  template&lt;typename Derived&gt;
  void f(const Eigen::MatrixBase&lt;Derived&gt;&amp;) // (1)
  {
      PRINT_MY_NAME;
  }
  
  template&lt;typename Derived&gt;
  void f(Eigen::MatrixBase&lt;Derived&gt;&amp;&amp;)      // (2)
  {
      PRINT_MY_NAME;
  }
  
  int main()
  {
      Eigen::MatrixXd A;
  
      f(A);     // invokes (1)
      f(A + A); // invokes also (1) !!!
  }
  </code></pre>
  <p>which outputs (gcc5.2)</p>
  <blockquote>
  <p>void f(const Eigen::MatrixBase&amp;) [with Derived = Eigen::Matrix &lt; double, -1, -1&gt;]</p>
  <p>void f(const Eigen::MatrixBase&amp;) [with Derived = Eigen::CwiseBinaryOp &lt; Eigen::internal::scalar_sum_op &lt; double&gt;, const Eigen::Matrix &lt; double, -1, -1&gt;, const Eigen::Matrix &lt; double, -1, -1&gt; &gt;]</p>
  </blockquote>
  <p>so clearly the rvalue overload is not considered. It is now clear for me that the second one is not a better match, since I pass a rvalue Eigen expression, which is convertible to <code>Eigen::MatrixBase&lt;&gt;</code>, but is not the exact same type. Now comes my question:</p>
  <ul>
  <li>How can I disable or detect rvalue Eigen expressions passed as parameters for <code>f</code>? The issue is that an expression can have an arbitrary type (Eigen uses expression templates), like <code>CwiseBinaryOp&lt;...CwiseBinaryOp&lt;...&gt;&gt;</code> and so on. This is part of a larger problem in which I have a utility make-like function which takes a lvalue and binds it to a <code>const</code> reference expression in a class. If the expression is a rvalue, then all bets are off, since reference binding is not propagating via a constructor argument, so I want to forbid passing rvalue Eigen expressions.</li>
  </ul>