New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fs.path.generic.obs] and [fs.path.modifiers]p2, wording of make_preferred
and generic_*
is ambiguous
#5473
Comments
@jwakely Would you agree that changing this wording to clearly require the behavior exhibited by all surveyed implementations is editorial, or do you think LWG needs to discuss the question? |
I take it that, on Windows, the directory-separator Beyond that, this issue feels like it's possibly taking away implementation freedom, so handling this via an LWG issue appears to be preferable. Unless there is additional context elsewhere (e.g. examples) that makes the proposed interpretation the only plausible one. |
For If we did want to change the The wording for What should If the intent for For
I agree (except that
That's not what libstdc++ does on POSIX or Windows. It produces The code to do that is in I agree that Boost returns |
See STL issue microsoft/STL#2082.
make_preferred
The wording of
make_preferred
is:Effects: Each directory-separator of the pathname in the generic format is converted to preferred-separator.
And the definition of directory-separator is:
directory-separator:
in other words,
/
and\
are both directory separators on Windows, but so are//
,///
,////
,\\\\
.Thus, an implementation, given
path p{"a//b"}; p.make_preferred();
could either say:/
is a directory-separator, and/
is a directory-separator, so replace each of them with\
->p.native() == LR"(a\\b)"
//
is a directory-separator, so replace it with\
->p.native() == LR"(a\b)"
All implementations currently take the first approach, including MSVC STL, libstdc++, libc++, and boost::filesystem.
generic_string
(and othergeneric_*
functions)The wording of the generic format observer functions is:
Generic format observer functions return strings formatted according to the generic pathname format. A single slash ('
/
') character is used as the directory-separator.(emphasis mine)
This implies to me that
path{"a//b"}.generic_string() == LR("a/b")
, since//
is considered "one directory-separator" for purposes of the generic format. All implementations, however, just replace every singular preferred-separator with a fallback-separator if it's defined, otherwise they return the same thing asp.string()
.The text was updated successfully, but these errors were encountered: