STD::FILESYSTEM_DIRECTORY_ITERATOR(3)

πŸ“¦ version 11.5.0, in centos-stream 9

πŸ’… std::filesystem::directory_iterator β€” Library Functions Manual

okay so bestie, imagine a little iterator guy whose whole personality is "I go through one (1) directory's entries, one at a time" ✨ that's literally this. no cap, that's the whole vibe of std::filesystem::directory_iterator β€” an iterator type for traversing the entries in a single directory, periodt. πŸŽ€


✨ SYNOPSIS ✨

πŸ¦‹ Public Types

the glow-up lineup, aka what this iterator is on the inside:

  • typedef ptrdiff_t difference_type β€” the difference type, for when you gotta measure distance between two of these bad boys.
  • typedef input_iterator_tag iterator_category β€” yep, it's officially an input iterator. it's giving "read-only, get in, get out". πŸƒβ€β™€οΈ
  • typedef const directory_entry * pointer β€” pointer to a const directory_entry. no touching, only admiring.
  • typedef const directory_entry & reference β€” same energy but a reference. immaculate.
  • typedef directory_entry value_type β€” the actual thing you get when you dereference it: a directory_entry. main character energy, honestly.

πŸ’– Public Member Functions

every single one, and yes we're listing them all because we don't skip:

  • directory_iterator (const directory_iterator &__rhs)=default β€” copy constructor, defaulted, because the compiler's version ate and left no crumbs.
  • directory_iterator (const path &__p) β€” build one over the directory at path __p.
  • directory_iterator (const path &__p, directory_options __options) β€” same, but you get to pass directory_options __options to tweak the behaviour.
  • directory_iterator (const path &__p, directory_options __options, error_code &__ec) β€” the version with __options and an error_code &__ec so errors go into __ec instead of getting thrown at you.
  • directory_iterator (const path &__p, error_code &__ec) β€” just the path plus error_code &__ec. errors get parked in __ec, no drama. πŸ™ˆ
  • directory_iterator (directory_iterator &&__rhs) noexcept=default β€” move constructor, noexcept, defaulted. slay.
  • directory_iterator & increment (error_code &__ec) β€” the actual advancing-but-report-errors-into-__ec move, returns *this. πŸ’…
  • const directory_entry & operator* () const noexcept β€” dereference, const, noexcept, gives you the directory_entry you're currently sitting on.
  • directory_iterator & operator++ () β€” prefix increment. go to the next entry, return *this.
  • __directory_iterator_proxy operator++ (int) β€” postfix increment (the int dummy arg), returns a __directory_iterator_proxy. iconic little proxy moment.
  • const directory_entry * operator-> () const noexcept β€” arrow operator, const, noexcept, hands you a const directory_entry *.
  • directory_iterator & operator= (const directory_iterator &__rhs)=default β€” copy assignment, defaulted.
  • directory_iterator & operator= (directory_iterator &&__rhs) noexcept=default β€” move assignment, noexcept, defaulted. we love a clean handoff. ✨

🫢 Friends

not our functions, but they're in the group chat:

  • bool operator!= (const directory_iterator &__lhs, const directory_iterator &__rhs) noexcept β€” are these two NOT the same? noexcept, obviously.
  • bool operator== (const directory_iterator &__lhs, const directory_iterator &__rhs) noexcept β€” are these two the same? also noexcept. comparing iterators is self-care. ⭐
  • class recursive_directory_iterator β€” listed as a friend class. the more chaotic cousin. (iykyk)
heads up bestie: these are not member functions, okay? don't come for me. they're just chilling here.
  • directory_iterator begin (directory_iterator __iter) noexcept β€” enable range-based for using directory_iterator. literally just so you can write for (auto &e : it) and feel like a genius. 🧚
  • directory_iterator end (directory_iterator) noexcept β€” return a past-the-end directory_iterator. the finish line, the end of the scroll, the final boss.

πŸ’œ Detailed Description πŸ’œ

Iterator type for traversing the entries in a single directory. πŸ—‚οΈ

that's it. that's the whole deal. one directory, entries, traversed. you're doing amazing sweetie.


🌈 Author 🌈

Generated automatically by Doxygen for libstdc++ from the source code. so like, a robot wrote this one, but it understood the assignment fr fr. πŸ€–πŸ’–


ok that's the whole page, no notes. go forth and iterate responsibly, bestie πŸ¦‹

libstdc++ Β· Wed Oct 7 2026 Β· and that's the sign-off for std::files...ry_iterator(3) β€” mwah πŸ’‹ βœ§γƒ»οΎŸ: βœ§γƒ»οΎŸ:

πŸ“¦ where this page comes from