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.

2723. Do directory_iterator and recursive_directory_iterator become the end iterator upon error?

Section: 31.12.11 [fs.class.directory.iterator], 31.12.12 [fs.class.rec.dir.itr] Status: C++17 Submitter: Eric Fiselier Opened: 2016-05-28 Last modified: 2021-06-06

Priority: 0

View all other issues in [fs.class.directory.iterator].

View all issues with C++17 status.

Discussion:

Constructing or performing an increment on directory iterator types can result in an error. Currently there is implementation divergence regarding the value of the iterator after an error occurs. Both boost and libc++ construct the end iterator. libstdc++ constructs a singular iterator which is not equal to the end iterator. For this reason we should clarify the state of the iterators after an error occurs.

[2016-06 Oulu]

Moved to P0/Ready during issues prioritization.

Friday: status to Immediate

Proposed resolution:

This wording is relative to N4582.

  1. Modify [fs.class.directory_iterator] as follows:

    -3- If an iterator of type directory_iterator reports an error or is advanced past the last directory element, that iterator shall become equal to the end iterator value. The directory_iterator default constructor shall create an iterator equal to the end iterator value, and this shall be the only valid iterator for the end condition.