title: Write overloads for const reference and rvalue reference
body: <p>Recently I find myself often in the situation of having a single function that takes some object as a parameter. The function will have to copy that object.</p>
  <p>However the parameter for that function may also quite frequently be a temporary and thus I want to also provide an overload of that function that takes an rvalue reference instead a const reference.</p>
  <p>Both overloads tend to only differ in that they have different types of references as argument types. Other than that they are functionally equivalent.</p>
  <p>For instance consider this toy example:</p>
  <pre><code>void foo(const MyObject &amp;obj) {
      globalVec.push_back(obj); // Makes copy
  }
  void foo(MyObject &amp;&amp;obj) {
      globalVec.push_back(std::move(obj)); // Moves
  }
  </code></pre>
  <p>Now I was wondering whether there is a way to avoid this code-duplication by e.g. implementing one function in terms of the other.</p>
  <p>For instance I was thinking of implementing the copy-version in terms of the move-one like this:</p>
  <pre><code>void foo(const MyObject &amp;obj) {
      MyObj copy = obj;
      foo(std::move(copy));
  }
  void foo(MyObject &amp;&amp;obj) {
      globalVec.push_back(std::move(obj)); // Moves
  }
  </code></pre>
  <p>However this still does not seem ideal since now there is a copy AND a move operation happening when calling the const ref overload instead of a single copy operation that was required before.</p>
  <p>Furthermore, if the object does not provide a move-constructor, then this would effectively copy the object twice (afaik) which defeats the whole purpose of providing these overloads in the first place (avoiding copies where possible).</p>
  <p>I'm sure one could hack something together using macros and the preprocessor but I would very much like to avoid involving the preprocessor in this (for readability purposes).</p>
  <p>Therefore my question reads: Is there a possibility to achieve what I want (effectively only implementing the functionality once and then implement the second overload in terms of the first one)?</p>
  <p>If possible I would like to avoid using templates instead.</p>