title: C++ unable to return a vector template
body: <p>I am trying to write a function that will convert a generic list to a vector, however, I cannot get my function to compile.  Here is my code (which sits in a .h file):</p>
  
  <pre><code>template &lt;class T&gt;
  inline std::vector&lt;T&gt; list2vector(std::list&lt;T&gt; &amp;l)
  {
    std::vector&lt;T&gt; v;
    v.insert(v.begin(),l.begin(),l.end());
    return v;
  }
  </code></pre>
  
  <p>Can anybody point out what I am missing here?
  The compiler error is the following:</p>
  
  <pre><code>find_rpeat.cpp:85: error: invalid initialization of non-const reference of type
  ?std::vector&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt;&amp;?
  from a temporary of type
  ?std::vector&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt;?
  </code></pre>