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.

### 2706. Error reporting for `recursive_directory_iterator::pop()` is under-specified

Section: 31.12.12 [fs.class.rec.dir.itr] Status: C++17 Submitter: Eric Fiselier Opened: 2016-05-09 Last modified: 2017-07-30

Priority: 0

View all issues with C++17 status.

Discussion:

Unlike `increment`, `pop()` does not specify how it reports errors nor does it provide a `std::error_code` overload. However implementing `pop()` all but requires performing an increment, so it should handle errors in the same way.

Proposed resolution:

This wording is relative to N4582.

1. Change 31.12.12 [fs.class.rec.dir.itr], class `recursive_directory_iterator` synopsis, as indicated:

   >     namespace std::filesystem {
   >       class recursive_directory_iterator {
   >       public:
   >         […]
   >         void pop();
   >         void pop(error_code& ec);
   >         void disable_recursion_pending();
   >         […]
   >       };
   >     }

2. Change 31.12.12.2 [fs.rec.dir.itr.members] as indicated:

   >     void pop();
   >     void pop(error_code& ec);

   > > -30- Requires: `*this != recursive_directory_iterator()`.

   > > -31- Effects: If `depth() == 0`, set `*this` to `recursive_directory_iterator()`. Otherwise, cease iteration of the directory currently being iterated over, and continue iteration over the parent directory.

   > > -?- Throws: As specified in Error reporting (31.5.6 [error.reporting]).