std::filesystem::begin(recursive_directory_iterator), std::filesystem::end(recursive_directory_iterator) - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

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

From cppreference.com
< cpp‎ | filesystem‎ | recursive directory iterator

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

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_iterator`s with range-based for loops.

### [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

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

Possible output:

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

### [edit] See also

begin(std::filesystem::directory_iterator)end(std::filesystem::directory_iterator) | range-based for loop support (function) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/filesystem/recursive_directory_iterator/begin&oldid=91621"
Category:

- unconditionally noexcept

Hidden categories:

- Pages with unreviewed unconditional noexcept template
- Pages with unreviewed noexcept template