##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::filesystem::directory_iterator::directory_iterator

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

directory_iterator(); | (1) | (since C++17)
explicit directory_iterator( const std::filesystem::path& p ); | (2) | (since C++17)
directory_iterator( const std::filesystem::path& p, std::error_code& ec ); | (3) | (since C++17)
directory_iterator( const directory_iterator& ) = default; | (4) | (since C++17)
directory_iterator( directory_iterator&& ) = default; | (5) | (since C++17)

Constructs a new directory iterator.

1) Constructs the end iterator.
2) Constructs a directory iterator that refers to the first directory entry of a directory identified by `p`. If `p` refers to an non-existing file or not a directory, returns the end iterator.

### [edit] Parameters

| This section is incomplete

### [edit] Exceptions

1)
`noexcept` specification:
noexcept
2) std::filesystem::filesystem_error if an error occurs. The exception object is constructed with `p` as an argument.
3)
`noexcept` specification:
noexcept

### [edit] Notes

To iterate over the current directory, construct the iterator as directory_iterator(".") instead of directory_iterator("").

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/filesystem/directory_iterator/directory_iterator&oldid=91537"
Categories:

- Todo without reason
- unconditionally noexcept

Hidden categories:

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