This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++17 status.
Section: 22.214.171.124 [fs.op.exists] Status: C++17 Submitter: Jonathan Wakely Opened: 2016-06-06 Last modified: 2017-07-30
View all issues with C++17 status.
The filesystem::exists(const path&) function does not throw an exception if the file doesn't exist, but the corresponding function taking an error_code& argument does set it to indicate an error.It seems sensible for filesystem::exists(const path&, error_code&) to call ec.clear() if status(p, ec).type() == file_type::not_found.
[2016-06, Oulu — Jonathan comments and provides wording]
The sentence "The signature with argument ec returns false if an error occurs." means that given a file such that status(p).type() == file_type::unknown, exists(p) is true but exists(p, ec) is false.I believe we should make the behaviour of exists(p) and exists(p, ec) consistent, so that the latter clears ec except when the former would throw an exception, which is only for the file_type::none case.
Prioritized as P1
Voted to Ready 7-0 Tuesday evening in Oulu
This wording is relative to N4594.
Insert a new paragraph before 126.96.36.199 [fs.op.exists] p2 and edit it as shown:
bool exists(const path& p); bool exists(const path& p, error_code& ec) noexcept;
exists(status(p)) or exists(status(p, ec)), respectively. The signature with argument ec returns false if an error occurs.