recursive_directory_iterator begin( recursive_directory_iterator iter ) noexcept; | (1) | (since C++17) |
recursive_directory_iterator end( const recursive_directory_iterator& ) noexcept; | (2) | (since C++17) |
iter
unchangedrecursive_directory_iterator
, which serves as the end iterator. The argument is ignored.These non-member functions enable the use of recursive_directory_iterator
s with range-based for loops.
iter | - | a recursive_directory_iterator |
iter
unchangedrecursive_directory_iterator
)#include <fstream> #include <iostream> #include <filesystem> namespace fs = std::filesystem; int main() { fs::create_directories("sandbox/a/b"); std::ofstream("sandbox/file1.txt"); fs::create_symlink("a", "sandbox/syma"); for(auto& p: fs::recursive_directory_iterator("sandbox")) std::cout << p << '\n'; fs::remove_all("sandbox"); }
Possible output:
"sandbox/a" "sandbox/a/b" "sandbox/file1.txt" "sandbox/syma"
range-based for loop support (function) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/filesystem/recursive_directory_iterator/begin