Paul92
Paul92

Reputation: 9062

Order of traversal given by std::filesystem directory_iterator

When iterating through a directory using std::filesystem::directory_iterator, are there any guarantees regarding the order of traversal?

Upvotes: 0

Views: 548

Answers (2)

NathanOliver
NathanOliver

Reputation: 180825

The order is unspecified per [fs.class.directory.iterator]/8

The order of directory entries obtained by dereferencing successive increments of a directory_­iterator is unspecified.

Upvotes: 3

NutCracker
NutCracker

Reputation: 12273

From the docs:

The iteration order is unspecified, except that each directory entry is visited only once. The special pathnames dot and dot-dot are skipped.

Upvotes: 4

Related Questions