Namespaces
Variants
Views
Actions

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

From cppreference.com
< cpp‎ | experimental‎ | fs‎ | recursive directory iterator
Revision as of 06:07, 16 July 2023 by Andreas Krug (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
 
 
Experimental
Technical Specification
Filesystem library (filesystem TS)
Library fundamentals (library fundamentals TS)
Library fundamentals 2 (library fundamentals TS v2)
Library fundamentals 3 (library fundamentals TS v3)
Extensions for parallelism (parallelism TS)
Extensions for parallelism 2 (parallelism TS v2)
Extensions for concurrency (concurrency TS)
Extensions for concurrency 2 (concurrency TS v2)
Concepts (concepts TS)
Ranges (ranges TS)
Reflection (reflection TS)
Mathematical special functions (special functions TR)
Experimental Non-TS
Pattern Matching
Linear Algebra
std::execution
Contracts
2D Graphics
 
 
 
recursive_directory_iterator begin( recursive_directory_iterator iter );
(1) (filesystem TS)
recursive_directory_iterator end( const recursive_directory_iterator& );
(2) (filesystem TS)
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.

Contents

[edit] Parameters

iter - a recursive_directory_iterator

[edit] Return value

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

[edit] Exceptions

noexcept specification:  
noexcept
  

[edit] Example

#include <experimental/filesystem>
#include <fstream>
#include <iostream>
namespace fs = std::experimental::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"

[edit] See also

range-based for loop support
(function) [edit]