operator==,!=,<,<=,>,>=,<=>(std::filesystem::path)

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

# 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

DRApplied toBehavior as publishedCorrect behavior
LWG 3065C++17allowed comparison of everything convertible to path in the presence of a using-directivemade hidden friend

# See also