This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of NAD status.

### 2761. `directory_entry` comparisons are members

Section: 29.12.10.4 [fs.dir.entry.obs] Status: NAD Submitter: Ville Voutilainen Opened: 2016-08-03 Last modified: 2017-03-19

Priority: 2

View all other issues in [fs.dir.entry.obs].

View all issues with NAD status.

Discussion:

The comparison operators for `directory_entry` are member functions (29.12.10.4 [fs.dir.entry.obs]).

That means that a `directory_entry` can be compared with a `path`, but a `path` cannot be compared with a `directory_entry`, because the left-hand side is not subject to conversions. This seems unfortunate.

Note that the comparisons for `path` are non-members (29.12.6.8 [fs.path.nonmember]).

The meta-p/r is to turn the `directory_entry` comparisons into non-member functions.

[2016-08 Chicago]

Wed PM: Priority 2

[2016-10-05 Ville provides concrete wording]

[2016-10 Telecon]

This (comparing a `path` with a `directory_entry`) works today w/o any changes. Closing as NAD.

Proposed resolution:

This wording is relative to N4606.

1. In [fs.class.directory_entry] synopsis, edit as follows:

   >     namespace std::filesystem {
   >     class directory_entry {
   >     public:
   >       […]
   >       bool operator< (const directory_entry& rhs) const noexcept;
   >       bool operator==(const directory_entry& rhs) const noexcept;
   >       bool operator!=(const directory_entry& rhs) const noexcept;
   >       bool operator<=(const directory_entry& rhs) const noexcept;
   >       bool operator> (const directory_entry& rhs) const noexcept;
   >       bool operator>=(const directory_entry& rhs) const noexcept;

   >     private:
   >       path pathobject; // exposition only
   >     };

   >     bool operator< (const directory_entry& lhs, const directory_entry& rhs) noexcept;
   >     bool operator==(const directory_entry& lhs, const directory_entry& rhs) noexcept;
   >     bool operator!=(const directory_entry& lhs, const directory_entry& rhs) noexcept;
   >     bool operator<=(const directory_entry& lhs, const directory_entry& rhs) noexcept;
   >     bool operator> (const directory_entry& lhs, const directory_entry& rhs) noexcept;
   >     bool operator>=(const directory_entry& lhs, const directory_entry& rhs) noexcept;

   >     }

2. In 29.12.10.4 [fs.dir.entry.obs]/6-11, edit as follows:

   >     bool operator==(const directory_entry& lhs, const directory_entry& rhs) const noexcept;

   > > -6- Returns: `pathobjectlhs.path() == rhs.pathobjectpath()`.

   >     bool operator!=(const directory_entry& lhs, const directory_entry& rhs) const noexcept;

   > > -7- Returns:: `pathobjectlhs.path() != rhs.pathobjectpath()`.

   >     bool operator< (const directory_entry& lhs, const directory_entry& rhs) const noexcept;

   > > -8- Returns:: `pathobjectlhs.path() < rhs.pathobjectpath()`.

   >     bool operator<<=(const directory_entry& lhs, const directory_entry& rhs) const noexcept;

   > > -9- Returns:: `pathobjectlhs.path() <= rhs.pathobjectpath()`.

   >     bool operator> (const directory_entry& lhs, const directory_entry& rhs) const noexcept;

   > > -10- Returns:: `pathobjectlhs.path() > rhs.pathobjectpath()`.

   >     bool operator>=(const directory_entry& lhs, const directory_entry& rhs) const noexcept;

   > > -11- Returns:: `pathobjectlhs.path() >= rhs.pathobjectpath()`.