std::filesystem::directory_iterator::operator++,std::filesystem::directory_iterator::increment (3) - Linux Manuals

std::filesystem::directory_iterator::operator++,std::filesystem::directory_iterator::increment: std::filesystem::directory_iterator::operator++,std::filesystem::directory_iterator::increment


std::filesystem::directory_iterator::operator++,std::filesystem::directory_iterator::increment - std::filesystem::directory_iterator::operator++,std::filesystem::directory_iterator::increment


directory_iterator& operator++(); (since C++17)
directory_iterator& increment( std::error_code& ec );

Advances the iterator to the next entry. Invalidates all copies of the previous value of *this.

 This section is incomplete


ec - error code to store error status to

Return value



The overload that does not take a std::error_code& parameter throws filesystem_error on underlying OS API errors, constructed with the OS error code as the error code argument. The overload taking a std::error_code& parameter sets it to the OS API error code if an OS API call fails, and executes ec.clear() if no errors occur. Any overload not marked noexcept may throw std::bad_alloc if memory allocation fails.

Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DR Applied to Behavior as published Correct behavior
LWG_3013 C++17 error_code overload marked noexcept but can allocate memory noexcept removed