title: Howto call an unmanaged C++ function with a std::vector as parameter from C#?
body: <p>I have a C# front end and a C++ backend for performance reasons.
  Now I would like to call a C++ function like for example:</p>
  
  <pre><code>void findNeighbors(Point p, std::vector&lt;Point&gt; &amp;neighbors, double maxDist);
  </code></pre>
  
  <p>What I'd like to have is a C# wrapper function like:</p>
  
  <pre><code>List&lt;Point&gt; FindNeigbors(Point p, double maxDist);
  </code></pre>
  
  <p>I could pass a flat array like Point[] to the unmanaged C++ dll, but the problem is, that I don't know how much memory to allocate, because I don't know the number of elements the function will return...</p>
  
  <p>Is there an elegant way to handle this without having troubles with memory leaks?</p>
  
  <p>Thanks for your help!</p>
  
  <p>Benjamin</p>