std::filesy...operator++,(3)
β¨ NAME β¨
okay so this is the std::filesy...operator++,(3) page from the C++ Standard Libary (yes, βLibaryβ is literally in the header β we love a typo moment π). The NAME line is std::filesystem::recursive_directory_iterator::operator++, β then a -, then std::filesystem::recursive_directory_iterator::operator++, again. Itβs giving βtwo icons, same nameβ β¨.
π¦ Synopsis π¦
recursive_directory_iterator& operator++(); (1)
recursive_directory_iterator& increment( std::error_code& ec ); (2)
Both overloads are (since C++17). Highkey important. These advance the iterator to the next entry, and all copies of the previous value of *this get invalidated β so donβt go using stale copies after, bestie π.
When the current directory runs out of entries, iteration resumes over the parent directory. Rinse and repeat if the parent directory has no sibling entries that can to be iterated on (yes, that is the pageβs wording, not mine π« ). When you hit the parent of the whole directory hierarchy that has been recursively iterated on β as in, there are no candidate entries at depth() == 0 β *this is set to an end iterator. Thatβs the end, literally.
Otherwise, if *this refers to a directory, it gets iterated into only when these conditions hit:
disable_recursion_pending()has not been called before this increment, i.e.recursion_pending() == true.- The directory is not a symlink or following symlinks is enabled, i.e., at least one of the following is true:
!is_symlink((*this)->symlink_status()).(options() & directory_options::follow_directory_symlink) != directory_options::none)
π Parameters π
ecβ error code to store the error status to.
π Return value π
*this β thatβs the whole vibe.
π Exceptions π
- Any overload not marked
noexceptmay throwstd::bad_allocif memory allocation fails.
- Throws
std::filesystem::filesystem_erroron underlying OS API errors, constructed with the OS error code as the error code argument. - Sets a
std::error_code¶meter to the OS API error code if an OS API call fails, and executesec.clear()if no errors occur.
πΈ Example πΈ
This section is incomplete Reason: no example
not me crying over the missing example π
π Defect reports π
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
- DR
LWG 3013β applied to C++17. Behavior as published: theerror_codeoverload was markednoexceptbut can allocate memory. Correct behavior:noexceptremoved. π
π§ Category π§
- Todo no example
xoxo, your Unix bestie π
β footer flex: source/version http://cppreference.com, date 2024.06.10, page id std::filesy...operator++,(3). π«Ά
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms