title: Proper syntax to assign std::vector to a specific memory location on the heap?
body: <p>I am trying to implement the directions in these two SO posts regarding assigning containers to specific memory locations on the heap:</p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/2244010/moving-c-objects-especially-stl-containers-to-a-specific-memory-location">Moving C++ objects, especially stl containers, to a specific memory location</a></li>
  <li><a href="https://stackoverflow.com/questions/8301043/create-objects-in-pre-allocated-memory">Create objects in pre-allocated memory</a></li>
  </ol>
  
  <p>However, I must be doing something stupid (I'm new to C++) because I can't even get my code to compile (using C++ 11 as you can see below):</p>
  
  <pre><code>  std::vector&lt;int&gt; ints1 = {10, 20, 30};
    ints1.reserve(20);
    auto adr = &amp;(*ints1.end());
    auto *ints2 = new(adr)(std::vector&lt;int&gt;(20);
  </code></pre>
  
  <p>I am getting an error of a <code>expected , or ; before )</code> for the last line, which I take to mean that my syntax is just wrong, but how?</p>
  
  <p>Also, once I fix this syntax, what's the best way to ensure these objects really are contiguous? I thought I would ensure that </p>
  
  <pre><code>&amp;(*ints1.begin()) - &amp;(*ints2.begin) is roughly on the order of sizeof(std::vector&lt;int&gt; v(20));
  </code></pre>
  
  <p>Is there a better way? </p>
  
  <p>(p.s. I do realize I should allocate the memory I am going to use to do this to avoid undefined behavior)</p>