title: Decoupling type traits definition from implementation
body: <p>Lets consider the following class which checks if the type provided is a string and uses type traits to call a different function based on the result. The original source has type dependencies on Obj, this is a simplified example:</p>
  
  <pre><code>template &lt;typename Obj&gt; 
  class example {
      public:            
          template &lt;bool IdIsString = std::is_same&lt;std::string, Obj&gt;::value&gt;
          typename std::enable_if&lt;IdIsString, void&gt;::type
          doStuff() {
              this-&gt;object-&gt;doSomething();
          }
  
          template &lt;bool IdIsString = std::is_same&lt;std::string, Obj&gt;::value&gt;
          typename std::enable_if&lt;!IdIsString, void&gt;::type
          doStuff()  {
              this-&gt;object-&gt;doSomethingElse();
          }
       private:
          AnyObject object;
  };
  </code></pre>
  
  <p>How would I go about decoupling the definition (e.g. storing it in a example_inline.hpp) from the class without providing each type trait case in the definition?</p>
  
  <p>An ideal solution would look like this:</p>
  
  <pre><code>// header.hpp
  template &lt;typename Obj&gt; 
  class example {
      public:
          void doStuff(); 
  }
  
  // header_inline.hpp
  template &lt;typename Obj&gt;
  template &lt;bool IdIsString = std::is_same&lt;std::string, Obj&gt;::value&gt;
  typename std::enable_if&lt;IdIsString, void&gt;::type
  example::doStuff() {
     // ...
  }
  
  // ...
  </code></pre>
  
  <p>The above is obviously not possible. One solution would be to decouple the type_trait function from the class and put it into a detail namespace but this would mean that I would have to always pass AnyObject (and in that sense, all objects that are modified by the function) to it which seems not very elegant. </p>
  
  <p>Is there a good solution for this problem? I'd really like for the headers in question be easily readable without cluttering them with tons of enable_if's.</p>
  
  <p>Thanks for any input on the matter.</p>