title: pybind11, convert std::vector to py::list
body: <p>According to the pybind11 documentation <a href="https://pybind11.readthedocs.io/en/stable/advanced/cast/stl.html" rel="nofollow noreferrer">https://pybind11.readthedocs.io/en/stable/advanced/cast/stl.html</a>:</p>
  
  <blockquote>
    <p>When including the additional header file pybind11/stl.h, conversions between std::vector&lt;>/std::list&lt;>/std::array&lt;>, std::set&lt;>/std::unordered_set&lt;>, and std::map&lt;>/std::unordered_map&lt;> and the Python list, set and dict data structures are automatically enabled.</p>
  </blockquote>
  
  <p>However, I cannot for the life of me get this to work. I suppose I am misunderstanding something, so I hope someone can clear it up for me.</p>
  
  <p>Here is what I expected to work:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>// Test
  std::vector&lt;double&gt; test_vec{1,2,3,4,5};
  py::list test_list = test_vec;
  py::list test_list2(test_vec);
  py::list test_list3 = py::cast&lt;py::list&gt;(test_vec);
  </code></pre>
  
  <p>And here are the errors:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>error: conversion from ‘std::vector&lt;double&gt;’ to non-scalar type ‘pybind11::list’ requested
      py::list test_list = test_vec;
  error: no matching function for call to ‘pybind11::list::list(std::vector&lt;double&gt;&amp;)’
      py::list test_list2(test_vec);
  error: no matching function for call to ‘cast(std::vector&lt;double&gt;&amp;)’
      py::list test_list3 = py::cast&lt;py::list&gt;(test_vec)
  </code></pre>
  
  <p>The docs say to look in <code>tests/test_stl.cpp</code> for examples of how this should work, however I'm afraid that I am having trouble deciphering what is happening in that file.</p>