title: How to get the last directory in a std::filesystem::path?
body: <p>I have a path to a directory and I want to get the name of that directory, using C++'s <code>std::filesystem</code>. For example, if the path was: </p>
  
  <pre><code>std::filesystem::path fake_path("C:\\fake\\path\\to\\my_directory\\");
  </code></pre>
  
  <p>I would want to get "my_directory".</p>
  
  <p>I've seen <a href="https://stackoverflow.com/questions/39275465/how-to-use-c-to-get-the-folder-directory-name-but-not-the-path-of-one-file-e">this answer</a> and initially assumed that what worked in <code>boost::filesystem</code> wasn't working in <code>std::filesystem</code>, though that may not be correct. Either way, I don't believe this is a duplicate because that one is specifically asking about <code>boost::filesystem</code> and a path that ends in a file. </p>
  
  <p>I can think of several other solutions, like getting <code>fake_path.end() - 2</code> or getting the string and splitting on the separator, but none of them are quite as simple as <code>fake_path.filename()</code> would've been.</p>
  
  <p>Is there a clean way of getting the last part of a directory's path, roughly equivalent to calling <code>.filename()</code> on a file's path?</p>