Boost C++ Libraries: Ticket #7545: filesystem::path::filename() specification wrong? https://svn.boost.org/trac10/ticket/7545 <p> According to the <a href="http://www.boost.org/doc/libs/1_51_0/libs/filesystem/doc/reference.html#Definitions">definition</a> section of the boost::filesystem documentation, </p> <ul><li>a <strong>path</strong> consists of a root-name, a root-directory and (as relative-path) a sequence of filenames (all optional) </li><li>a <strong>filename</strong> is the name of a file, with slashes explicitly forbidden as part of the filename </li></ul><p> With these definitions, paths consisting entirely of root-name and/or root-directory parts (like <code> "//net"</code>, <code> "//net/" </code> and <code> "/"</code>) do not contain filenames. </p> <p> On the other hand, the specification of path::filename() says </p> <blockquote> <p> <em> Returns: </em> <code> empty() ? path() : *--end() </code> </p> </blockquote> <p> without discrimination between the different parts. Consequently, </p> <ul><li><code> Path("//net").filename() == Path("//net") </code> </li><li><code> Path("/").filename() == Path("/") </code> </li></ul><p> instead of the expected empty <code>Path()</code>, and containing the forbidden slash. </p> <p> <strong>Proposed fix:</strong> <br /> To become consistent with the definitions, path::filename() should be specified as follows: </p> <blockquote> <p> <em> Returns: </em> <code> relative_path().empty() ? path() : *--end() </code> </p> </blockquote> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7545 Trac 1.4.3