title: std::enable_if not compiling (invalid template argument)
body: <p>I'm writing some code that should accept an std::unique_ptr and activate operator>> on its contents, filling the pointer if it is empty.</p>
  
  <p>I'm trying to limit unwanted calls by using SFINAE but I'm getting a bunch of error messages about template arguments being bad.</p>
  
  <p>The code:</p>
  
  <pre><code>#include "serializable.h"
  
  template &lt;class Archive, typename T&gt;
  Archive &amp;operator&gt;&gt;( Archive &amp;in, std::unique_ptr&lt;typename std::enable_if&lt;typename std::is_base_of&lt;Serializable, T&gt;::value, T&gt;::type&gt; &amp;ptr )
  {
      if ( !ptr )
          ptr.swap( Serializable::construct_from_stream( in ) ); // Constructs a Serializable derivative.
  
      in &gt;&gt; *ptr;
      return in;
  }
  </code></pre>
  
  <p>The errors:</p>
  
  <pre><code>// 1
  error: template argument 1 is invalid
   Archive &amp;operator&gt;&gt;( Archive &amp;in, std::unique_ptr&lt;typename std::enable_if&lt;typename std::is_base_of&lt;Serializable, T&gt;::value, T&gt;::type&gt; &amp;ptr )
                                                                                                                                       ^
  // 2
  error: template argument 2 is invalid
  
  // 3
  error: expected '::' before '&amp;' token
   Archive &amp;operator&gt;&gt;( Archive &amp;in, std::unique_ptr&lt;typename std::enable_if&lt;typename std::is_base_of&lt;Serializable, T&gt;::value, T&gt;::type&gt; &amp;ptr )
                                                                                                                                         ^
  // 4
  error: expected identifier before '&amp;' token
  
  // 5
  error: request for member 'swap' in 'ptr', which is of non-class type 'int'
           ptr.swap( Serializable::construct_from_stream( in ) );
               ^
  // 6
  error: type/value mismatch at argument 1 in template parameter list for 'template&lt;bool &lt;anonymous&gt;, class _Tp&gt; struct std::enable_if'
       std::unique_ptr&lt;typename std::enable_if&lt;typename std::is_base_of&lt;Serializable, T&gt;::value, Serializable&gt;::type&gt;
                                                                                                             ^
  // 7
  error: 'Serializable' has not been declared
       ptr.swap( Serializable::construct_from_stream( in ) );
                 ^
  </code></pre>
  
  <ul>
  <li>What is wrong with the code here?</li>
  <li>Is there a cleaner way of writing this? (Aside from the obvious "using std::unique_ptr" and such.)</li>
  </ul>
  
  <p>"enable_if_t" doesn't work. But I think it's just an extension of what I did wrong to make even enable_if not work in the first place.</p>
  
  <p>I can tell something is very wrong because I also get an error message about operator* being applied to an int... which shouldn't have slipped inside at all (had SFINAE been implemented correctly)!</p>
  
  <p>Another interesting issue here is the fact that the compiler doesn't recognize Serializable even though it's included just above it... If the answer is not trivial I'll look it up separately.</p>
  
  <p>I'm compiling using MinGW 4.9.2 x32 on QtCreator 3.4.2 / Qt 5.5.0.</p>
  
  <p>Thank you.</p>
  
  <p>EDIT: Please do not suggest to just create a function like this:</p>
  
  <pre><code>Archive &amp;operator&gt;&gt;( Archive &amp;in, std::unique_ptr&lt;Serializable&gt; &amp;ptr)...
  </code></pre>
  
  <p>I must know the actual type of the object sent to this function and can't rely on polymorphism.</p>