title: How correctly to remove code repetition in template function
body: <p>I have code like this ("spaceship"-like operator).</p>
  
  <pre><code>template &lt;class T&gt;
  int comparator(const T &amp;a, const T &amp;b){
      if (a &lt; b){
          return -1;
      }else if (a &gt; b){
          return +1;
      }
  
      return 0;
  }
  
  inline int comparator(const char *a, const char *b){
      return strcmp(a, b); // I never tried this, included just to get the idea
  }
  
  inline int comparator(char const a, char const b){
      return a - b;
  }
  
  inline int comparator(int const a, int const b){
      return a - b;
  }
  </code></pre>
  
  <p>How can I easily remove repetition for several signed types (char, short, int, long etc). I tried with SFINAE, but result was not very encouraging.</p>