Created on 2018-02-13.00:00:00 last changed 46 months ago
Proposed resolution:
This wording is relative to N4713.
All drafting notes from LWG 2989 apply here too.Modify [fs.filesystem.syn], header <filesystem> synopsis, as indicated:
[…] // [fs.path.nonmember], path non-member functions void swap(path& lhs, path& rhs) noexcept; size_t hash_value(const path& p) noexcept;bool operator==(const path& lhs, const path& rhs) noexcept; bool operator!=(const path& lhs, const path& rhs) noexcept; bool operator< (const path& lhs, const path& rhs) noexcept; bool operator<=(const path& lhs, const path& rhs) noexcept; bool operator> (const path& lhs, const path& rhs) noexcept; bool operator>=(const path& lhs, const path& rhs) noexcept; path operator/ (const path& lhs, const path& rhs);[…]
Modify [fs.path.nonmember] as indicated:
[…] friend bool operator< (const path& lhs, const path& rhs) noexcept; […] friend bool operator<=(const path& lhs, const path& rhs) noexcept; […] friend bool operator> (const path& lhs, const path& rhs) noexcept; […] friend bool operator>=(const path& lhs, const path& rhs) noexcept; […] friend bool operator==(const path& lhs, const path& rhs) noexcept; […] friend bool operator!=(const path& lhs, const path& rhs) noexcept; […] friend path operator/ (const path& lhs, const path& rhs); […]
Modify [fs.class.path], class path synopsis, as indicated:
class path { public: […] // [fs.path.modifiers], modifiers […] // [fs.path.nonmember], non-member operators friend bool operator< (const path& lhs, const path& rhs) noexcept; friend bool operator<=(const path& lhs, const path& rhs) noexcept; friend bool operator> (const path& lhs, const path& rhs) noexcept; friend bool operator>=(const path& lhs, const path& rhs) noexcept; friend bool operator==(const path& lhs, const path& rhs) noexcept; friend bool operator!=(const path& lhs, const path& rhs) noexcept; friend path operator/ (const path& lhs, const path& rhs); // [fs.path.native.obs], native format observers […] };
[ 2018-11, Adopted in San Diego ]
[ 2018-08-23 Batavia Issues processing ]
Status to Tentatively Ready
[ 2018-02-20, Priority set to 2 after mailing list discussion ]
Consider the following program:
// See godbolt link #include <assert.h> #include <string> #include <filesystem> using namespace std; using namespace std::filesystem; int main() { bool b = L"a//b" == std::string("a/b"); assert(b); // passes. What?! return b; }
L"a" gets converted into a path, and the string gets converted into a path, and then those paths are compared for equality. But path equality comparison doesn't work anything like string equality comparison, leading to surprises.
path's other operators should be made hidden friends as well, so that one side or the other of a given operator is of type path before those conversions apply.History | |||
---|---|---|---|
Date | User | Action | Args |
2021-02-25 10:48:01 | admin | set | status: wp -> c++20 |
2018-11-12 04:39:29 | admin | set | messages: + msg10192 |
2018-11-12 04:39:29 | admin | set | status: voting -> wp |
2018-10-08 05:13:59 | admin | set | status: ready -> voting |
2018-08-24 13:31:33 | admin | set | messages: + msg10127 |
2018-08-24 13:31:33 | admin | set | status: new -> ready |
2018-03-04 15:38:38 | admin | set | messages: + msg9713 |
2018-02-15 19:20:54 | admin | set | messages: + msg9686 |
2018-02-13 00:00:00 | admin | create |