[fs.class.rec.dir.itr.general]

# 31 Input/output library [[input.output]](./#input.output)

## 31.12 File systems [[filesystems]](filesystems#fs.class.rec.dir.itr.general)

### 31.12.12 Class recursive_directory_iterator [[fs.class.rec.dir.itr]](fs.class.rec.dir.itr#general)

#### 31.12.12.1 General [fs.class.rec.dir.itr.general]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16779)

An object of type recursive_directory_iterator provides an iterator for
a sequence of directory_entry elements representing the files in a
directory or in an implementation-defined directory-like file
type, and its subdirectories[.](#1.sentence-1)

namespace std::filesystem {class recursive_directory_iterator {public:using iterator_category = input_iterator_tag; using value_type = directory_entry; using difference_type = ptrdiff_t; using pointer = const directory_entry*; using reference = const directory_entry&; // [[fs.rec.dir.itr.members]](fs.rec.dir.itr.members "31.12.12.2 Members"), constructors and destructor recursive_directory_iterator() noexcept; explicit recursive_directory_iterator(const path& p);
 recursive_directory_iterator(const path& p, directory_options options);
 recursive_directory_iterator(const path& p, directory_options options,
 error_code& ec);
 recursive_directory_iterator(const path& p, error_code& ec);
 recursive_directory_iterator(const recursive_directory_iterator& rhs);
 recursive_directory_iterator(recursive_directory_iterator&& rhs) noexcept; ~recursive_directory_iterator(); // [[fs.rec.dir.itr.members]](fs.rec.dir.itr.members "31.12.12.2 Members"), observers directory_options options() const; int depth() const; bool recursion_pending() const; const directory_entry& operator*() const; const directory_entry* operator->() const; // [[fs.rec.dir.itr.members]](fs.rec.dir.itr.members "31.12.12.2 Members"), modifiers recursive_directory_iterator&operator=(const recursive_directory_iterator& rhs);
 recursive_directory_iterator&operator=(recursive_directory_iterator&& rhs) noexcept;

 recursive_directory_iterator& operator++();
 recursive_directory_iterator& increment(error_code& ec); void pop(); void pop(error_code& ec); void disable_recursion_pending(); bool operator==(default_sentinel_t) const noexcept {return *this == recursive_directory_iterator(); }// other members as required by [[input.iterators]](input.iterators "24.3.5.3 Input iterators"), input iterators};}

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16836)

Calling options, depth, recursion_pending,pop or disable_recursion_pending on an iterator that is not dereferenceable results in undefined behavior[.](#2.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16841)

The behavior of a recursive_directory_iterator is the same
as a directory_iterator unless otherwise specified[.](#3.sentence-1)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L16845)

[*Note [1](#note-1)*:

If the directory structure being iterated over contains cycles
then it is possible that the end iterator is unreachable[.](#4.sentence-1)

â *end note*]
