title: How to combine two boost::filesystem::path's?
body: <p>I need to combine an absolute path A with path B, given that B may be relative as well as absolute, preferably using <a href="http://www.boost.org/doc/libs/1_64_0/libs/filesystem/doc/index.htm" rel="nofollow noreferrer">boost::filesystem</a>.</p>
  
  <p>In other words, I want to have:</p>
  
  <ul>
  <li><code>/usr/home/</code> + <code>abc</code> = <code>/usr/home/abc</code></li>
  <li><code>/usr/home/</code> + <code>../abc</code> = <code>/usr/home/../abc</code> (or, even better <code>/usr/abc</code> - <em>this is <strong>not</strong> my question</em>)</li>
  <li><code>/usr/home/</code> + <code>/abc</code> = <code>/abc</code></li>
  </ul>
  
  <p>The first two are easy with the <code>/</code> operator but I can't get the third one to work.</p>
  
  <p>I tried:</p>
  
  <pre><code>std::cout &lt;&lt; boost::filesystem::path("/usr/home/") / "/abc";
  </code></pre>
  
  <p>Prints <code>/usr/home//abc</code>.</p>
  
  <pre><code>std::cout &lt;&lt; boost::filesystem::path("/usr/home/") + "/abc";
  </code></pre>
  
  <p>Still prints <code>/usr/home//abc</code>.</p>
  
  <p>Of course I can "see" when path B is absolute by looking at it and just use that, but I don't want to hardcode the check for the leading <code>/</code> because on Windows it can be different (e.g. <code>C:\\</code> or <code>\\</code>).</p>