Edit

<filesystem> operators

These nonmember operators for std::filesystem::path are declared in the C++17 <filesystem> header. The comparison operators compare two paths element by element in generic format by using path::compare, not as raw strings. Use the equivalent function to determine whether two paths (for example, a relative path and an absolute path) refer to the same file or directory on disk.

Note

This page documents the C++17 std::filesystem operators. For the historical prestandard operators that MSVC provided in <experimental/filesystem>, see <experimental/filesystem> operators.

For more information, see File System Navigation (C++).

Requirements

Header: <filesystem>

Namespace: std::filesystem

operator==

bool operator==(const path& left, const path& right) noexcept;

The function returns left.compare(right) == 0.

operator!=

bool operator!=(const path& left, const path& right) noexcept;

The function returns !(left == right).

operator<

bool operator<(const path& left, const path& right) noexcept;

The function returns left.compare(right) < 0.

operator<=

bool operator<=(const path& left, const path& right) noexcept;

The function returns !(right < left).

operator>

bool operator>(const path& left, const path& right) noexcept;

The function returns right < left.

operator>=

bool operator>=(const path& left, const path& right) noexcept;

The function returns !(left < right).

operator/

path operator/(const path& left, const path& right);

The function returns path(left) /= right.

operator<<

template <class Elem, class Traits>
basic_ostream<Elem, Traits>& operator<<(basic_ostream<Elem, Traits>& os, const path& pval);

The function inserts the path into the stream as a quoted string. It returns os << quoted(pval.string<Elem, Traits>()).

operator>>

template <class Elem, class Traits>
basic_istream<Elem, Traits>& operator>>(basic_istream<Elem, Traits>& is, path& pval);

The function extracts a quoted string from the stream and assigns it to pval. It executes:

basic_string<Elem, Traits> str;
is >> quoted(str);
pval = str;
return is;

See also

Header Files Reference
<filesystem>
File System Navigation (C++)