title: Can't deduce template parameter when helper template struct is used
body: <p>I would like to make some template functions work with existing template-struct helpers. However template argument deduction fails. Is there a work-around?</p>
  <h3>Example</h3>
  <p>This overloaded <code>operator &lt;&lt;</code> compiles and works:</p>
  <pre><code>template &lt;typename T&gt;
  inline typename std::vector&lt;T&gt;&amp;
  operator&lt;&lt;(
      typename std::vector&lt;T&gt;&amp; vec,
      const typename std::vector&lt;T&gt;::value_type&amp; val)
  {
      vec.push_back(val);
      return vec;
  }
  </code></pre>
  <p>But when I try to use a helper <code>struct</code> this doesn't compile:</p>
  <pre><code>template&lt;typename T&gt;
  struct Vector
  {
      typedef std::vector&lt;T&gt; Type;
  };
  
  template &lt;typename T&gt;
  inline typename Vector&lt;T&gt;::Type&amp;
  operator&lt;&lt;(
      typename Vector&lt;T&gt;::Type&amp; vec,
      const typename Vector&lt;T&gt;::Type::value_type&amp; val)
  {
      vec.push_back(val);
      return vec;
  }
  </code></pre>
  <p>gcc error:</p>
  <pre><code>error: no match for 'operator&lt;&lt;' (operand types are 'std::vector&lt;int&gt;' and 'int')
      ...
  note: candidate: 
  'template&lt;class T&gt; typename Vector&lt;T&gt;::Type&amp; operator&lt;&lt;
  (typename Vector&lt;T&gt;::Type&amp;, const typename Vector&lt;T&gt;::Type::value_type&amp;)'
   operator&lt;&lt;(
   ^~~~~~~~
  note:   template argument deduction/substitution failed:
  note:   couldn't deduce template parameter 'T'
  </code></pre>
  <p>clang error:</p>
  <pre><code>error: invalid operands to binary expression ('std::vector&lt;int&gt;' and 'int')
     vec &lt;&lt; int(2);
     ~~~ ^  ~~~~~~
  note: candidate template ignored: couldn't infer template argument 'T'
  operator&lt;&lt;(
  ^
  </code></pre>
  <p><kbd><a href="https://wandbox.org/permlink/nJv546A8uHLHRtg7" rel="nofollow noreferrer"><strong>Live example</strong></a></kbd></p>
  <h3>Question</h3>
  <ul>
  <li>What prevents a successful template parameter deduction in this case?</li>
  <li>Is there a <code>c++03</code> work-around for this case? Alias templates would solve the problem in <code>c++11</code>.</li>
  </ul>
  <p><strong>Note:</strong> In my real problem second parameter is not necessarily <code>T</code> and I can't use it to deduce vector type.</p>
  <p><strong>Note 2:</strong> the real helper struct contains some platform specific pre-processing and looks something like:</p>
  <pre><code>template &lt;class T&gt;
  struct Helper
  {
  #if defined(_WIN32_WCE)
      typedef std::vector&lt;T, WMHeapAllocator&lt;T&gt; &gt; Vector;  
  #else
      typedef std::vector&lt;T&gt; Vector;      
  #endif
  };
  </code></pre>