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

Section: 30.11.12 [fs.class.directory_iterator], 30.11.13 [fs.class.rec.dir.itr] Status: C++17 Submitter: Eric Fiselier Opened: 2016-05-28 Last modified: 2017-07-30

Priority: 0

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 30.11.12 [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.