Title
Misleading example for filesystem::path::filename()
Status
new
Section
[fs.path.decompose]
Submitter
Jonathan Wakely

Created on 2018-04-06.00:00:00 last changed 71 months ago

Messages

Date: 2018-06-19.05:49:11

Proposed resolution:

This wording is relative to N4741.

  1. Edit [fs.path.decompose] as indicated:

    path filename() const;
    

    -6- Returns: relative_path().empty() ? path() : *--end().

    [Example:

    path("/foo/bar.txt").filename(); // yields "bar.txt"
    path("/foo/bar").filename();     // yields "bar"
    path("/foo/bar/").filename();    // yields ""
    path("/").filename();            // yields ""
    path("//host").filename();       // yields ""
    path(".").filename();            // yields "."
    path("..").filename();           // yields ".."
    

    — end example]

Date: 2018-06-18.00:00:00

[ 2018-06-18 after reflector discussion ]

Priority set to 3

Date: 2018-04-15.00:00:00

[ 2018-04-10, Jonathan comments and provides revised wording ]

Based on the reflector discussion I'd like to change the P/R to Billy's suggestion of simply removing that line from the example.

Date: 2018-04-18.17:24:32

The example in [fs.path.decompose] p7 includes:

path("//host").filename();  // yields ""

This result isn't guaranteed, it depends whether the implementation interprets "//host" as a root-name or as a root-directory (with a redundant directory-separator) followed by the filename "host".

The example should make it clear that this interpretation is allowed.

Previous resolution [SUPERSEDED]:

This wording is relative to N4727.

  1. Edit [fs.path.decompose] as indicated:

    path filename() const;
    

    -6- Returns: relative_path().empty() ? path() : *--end().

    [Example:

    path("/foo/bar.txt").filename(); // yields "bar.txt"
    path("/foo/bar").filename();     // yields "bar"
    path("/foo/bar/").filename();    // yields ""
    path("/").filename();            // yields ""
    path("//host").filename();       // yields "" or "host"
    path(".").filename();            // yields "."
    path("..").filename();           // yields ".."
    

    — end example]

History
Date User Action Args
2018-06-19 05:49:11adminsetmessages: + msg9942
2018-04-18 17:24:32adminsetmessages: + msg9816
2018-04-08 15:39:55adminsetmessages: + msg9812
2018-04-06 00:00:00admincreate