std::experi...ion_pending(3)
Okay bestie, welcome to std::experi...ion_pending(3) from the C++ Standard Libary manual β yes, βLibary,β thatβs literally how itβs spelled in the header, and weβre keeping the facts exactly as they are π
.
β¨ NAME β¨
std::experimental::filesystem::recursive_directory_iterator::disable_recursion_pendingstd::experimental::filesystem::recursive_directory_iterator::disable_recursion_pending
Yes, the NAME section lists the whole mouthful twice. The original is committed to the bit, and so am I π.
πΈ Synopsis πΈ
void disable_recursion_pending(); (filesystem TS)
π¦ DESCRIPTION π¦
This one disables recursion to the currently referred subdirectory, if any. Slay.
The call modifies the pending recursion flag on the iterator in such a way that the next time increment is called, the iterator will advance within the current directory β the page says βdirectly,β and honestly? iconic typo behavior β even if it is currently referring to a subdirectory that hasnβt been visited.
The status of the pending recursion flag can be queried with recursion_pending(), which is false after this call. It is reset back to true after increment, and its initial value is also true.
π¨ UB ALERT: the behavior is undefined if *this is the end iterator. Do not do that, bestie. No cap, thatβs the dangerous one. π
π Parameters π
(none) β literally none.
π Return value π
(none) β it gives you nothing back, and thatβs valid.
π Exceptions π
May throw implementation-defined exceptions.
π₯ Example π₯
// Run this code
#include <experimental/filesystem>
#include <fstream>
#include <iostream>
#include <string>
namespace fs = std::experimental::filesystem;
int main()
{
fs::create_directories("sandbox/a/b/c");
fs::create_directories("sandbox/a/b/d/e");
std::ofstream("sandbox/a/b/file1.txt");
fs::create_symlink("a", "sandbox/syma");
for (auto i = fs::recursive_directory_iterator("sandbox");
i != fs::recursive_directory_iterator(); ++i)
{
std::cout << std::string(i.depth(), ' ') << *i;
if (fs::is_symlink(i->symlink_status()))
std::cout << " -> " << fs::read_symlink(*i);
std::cout << '\n';
// do not descend into "b"
if (i->path().filename() == "b")
i.disable_recursion_pending();
}
fs::remove_all("sandbox");
}
π Output π
"sandbox/a"
"sandbox/a/b"
"sandbox/syma" -> "a"
π«Ά See also π«Ά
recursion_pendingβ checks whether the recursion is disabled for the current directory (public member function).incrementβ advances to the next entry.operator++β (public member function).
π Category π
- Noindexed pages
Source/version and date vibes: http://cppreference.com, 2024.06.10, page std::experi...ion_pending(3). Byeee, bestie ππ
π¦ 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