operator==,!=,<,<=,>,>=,<=>(std::filesystem::path)
Min standard notice:
Compares two paths lexicographically.
# Declarations
friend bool operator==( const path& lhs, const path& rhs ) noexcept;
(since C++17)
friend bool operator!=( const path& lhs, const path& rhs ) noexcept;
(since C++17) (until C++20)
friend bool operator<( const path& lhs, const path& rhs ) noexcept;
(since C++17) (until C++20)
friend bool operator<=( const path& lhs, const path& rhs ) noexcept;
(since C++17) (until C++20)
friend bool operator>( const path& lhs, const path& rhs ) noexcept;
(since C++17) (until C++20)
friend bool operator>=( const path& lhs, const path& rhs ) noexcept;
(since C++17) (until C++20)
friend std::strong_ordering
operator<=>( const path& lhs, const path& rhs ) noexcept;
(since C++20)
# Parameters
lhs, rhs: the paths to compare
# Notes
Path equality and equivalence have different semantics.
In the case of equality, as determined by operator==, only lexical representations are compared. Therefore, path(“a”) == path(“b”) is never true.
In the case of equivalence, as determined by std::filesystem::equivalent(), it is checked whether two paths resolve to the same file system object. Thus equivalent(“a”, “b”) will return true if the paths resolve to the same file.
# Example
This section is incompleteReason: no example
# Defect reports
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 3065 | C++17 | allowed comparison of everything convertible to path in the presence of a using-directive | made hidden friend |