title: Specialized template dispatch independent of template parameter position
body: <p>I have come across the problem of needing a template function that will have the same output so long as it's template parameters are the same, independent of position. Given that there are always two parameters.</p>
  
  <p>I have a function:</p>
  
  <pre><code>template&lt;typename Lhs, typename Rhs&gt;
  int func();
  </code></pre>
  
  <p>I would like <code>func&lt;int, float&gt;()</code> and <code>func&lt;float, int&gt;()</code> to call the same code.</p>
  
  <p>I thought about a macro, which I like to avoid, but I need to not duplicate code when the two types are the same. So a macro such as:</p>
  
  <pre><code>#define DEF_TEMPL_IMPL(lhs, rhs, ret) \
  template&lt;&gt;\
  auto func&lt;lhs, rhs&gt;(){ return ret; }\
  template&lt;&gt;\
  auto func&lt;rhs, lhs&gt;(){ return func&lt;lhs, rhs&gt;(); }
  </code></pre>
  
  <p>will fail to compile because <code>DEF_TEMPL_IMPL(float, float, 3)</code> would cause a redefinition of <code>func&lt;&gt;</code></p>
  
  <p>I think SFINAE is the answer here, but can't quite think of a solution.</p>
  
  <p>I will continue to ponder this, but some of the great minds of stack overflow might have a much better or more elegant solution than I can come up with before this question is answered.</p>
  
  <p>So how can this be achieved?</p>