title: Why do trailing separators change the behavior of relative path conversions in Boost.Filesystem?
body: <p>Given the following code,</p>
  
  <pre class="lang-cpp prettyprint-override"><code>namespace fs = boost::filesystem;
  fs::path parentPath("/home/user1/");
  fs::path childPath("/home/user1/Downloads/Books");
  std::cout &lt;&lt; childPath.lexically_relative(parentPath) &lt;&lt; '\n';
  </code></pre>
  
  <p>I expect the output to be <code>"Downloads/Books"</code>, but instead it is <code>"../Downloads/Books"</code>. If I change the <code>parentPath</code> to <code>"/home/user1"</code> (removing the trailing separator), I do get my expected output.</p>
  
  <p>In my <em>real</em> code, the paths often times come in as strings from data. In my context, a trailing slash at the end is unintentional and should be ignored for the purposes of any logic. Basically, in my program <code>"/home/user1"</code> is identical to <code>"/home/user1/"</code>. However the logic of <code>boost::filesystem::path</code> doesn't reflect this assertion.</p>
  
  <p>So my question is two fold:</p>
  
  <ol>
  <li><p>Why does the trailing separator affect the behavior? I just can't quite understand why it steps up a directory with <code>".."</code> in this case.</p></li>
  <li><p>How can I make <code>path</code> ignore or normalize trailing slashes globally in my program? For example, "sanitizing" my path strings before I construct <code>path</code> objects would be too much of a maintenance burden, so I need something more inherent if possible.</p></li>
  </ol>
  
  <p>Here's a <a href="https://wandbox.org/permlink/ht2RbxuTcj667D97" rel="nofollow noreferrer">live sample</a> I've been using for testing.</p>