std::filesystem::begin(recursive_directory_iterator), (3) - Linux Man Pages

std::filesystem::begin(recursive_directory_iterator),: std::filesystem::begin(recursive_directory_iterator),

NAME

std::filesystem::begin(recursive_directory_iterator), - std::filesystem::begin(recursive_directory_iterator),

Synopsis


recursive_directory_iterator begin( recursive_directory_iterator   (1) (since C++17)
iter noexcept;
recursive_directory_iterator end( const                            (2) (since C++17)
recursive_directory_iterator& noexcept;


1) Returns iter unchanged
2) Returns a default-constructed recursive_directory_iterator, which serves as the
end iterator. The argument is ignored.


These non-member functions enable the use of recursive_directory_iterators with
range-based for loops.

Parameters


iter - a recursive_directory_iterator

Return value


1) iter unchanged
2) End iterator (default-constructed recursive_directory_iterator)

Example


// Run this code


 #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 << << '\n';
  fs::remove_all("sandbox");
 }

Possible output:


 "sandbox/a"
 "sandbox/a/b"
 "sandbox/file1.txt"
 "sandbox/syma"

See also


begin(std::filesystem::directory_iterator) range-based for loop support
end(std::filesystem::directory_iterator)   (function)