title: Boost Geometry: Union multiple polygons C++
body: <p>I have an array of several Boost.Geometry polygons, and I need to union them into a single polygon. I have successfully implemented something that merges each successive polygon with the union of the previous two (just looping through them and unioning another polygon). </p>
  
  <pre class="lang-cpp prettyprint-override"><code>multi_polygon polygons; // an array of initial polygons
  multi_polygon border;   // the unioned polygons
  
  for (polygon p : polygons) {
      // add another polygon each iteration
      multi_polygon tmp_poly;
      union_(border, p, tmp_poly);
      border = tmp_poly;
  }
  </code></pre>
  
  <p>However, this takes quite a long time to execute. I heard mention in a video that the <code>assign</code> function could be used for this, but it was not detailed how, and I couldn't find anything else about this. How can I speed up this process?</p>