title: Check if an std::filesystem::path is inside a directory
body: <p>I have a root path represented by an <code>std::filesystem::path</code>. I want to add some user provided filename to this path and make sure the resulting path is not out of the root directory.</p>
  
  <p>For example:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>    std::filesystem::path root = "/foo/bar";
      std::filesystem::path userFile = "ham/spam";
      std::filesystem::path finalPath = root / userFile;
  </code></pre>
  
  <p>The final path is ok, it is inside <code>/foo/bar</code>.
  But if I give <code>../ham/spam</code> to the <code>userFile</code> variable, this will result in a file outside the define <code>rootPath</code>.</p>
  
  <p>How can I check that the resulting file keeps inside its allowed boundaries ?</p>