STD::FILESYSTEM_DIRECTORY_ITERATOR(3)
π
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 aconst 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: adirectory_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 passdirectory_options__optionsto tweak the behaviour.directory_iterator (const path &__p, directory_options __options, error_code &__ec)β the version with__optionsand anerror_code &__ecso errors go into__ecinstead of getting thrown at you.directory_iterator (const path &__p, error_code &__ec)β just the path pluserror_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-__ecmove, returns*this. πconst directory_entry & operator* () const noexceptβ dereference,const,noexcept, gives you thedirectory_entryyou're currently sitting on.directory_iterator & operator++ ()β prefix increment. go to the next entry, return*this.__directory_iterator_proxy operator++ (int)β postfix increment (theintdummy arg), returns a__directory_iterator_proxy. iconic little proxy moment.const directory_entry * operator-> () const noexceptβ arrow operator,const,noexcept, hands you aconst 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? alsonoexcept. comparing iterators is self-care. βclass recursive_directory_iteratorβ listed as a friend class. the more chaotic cousin. (iykyk)
πΈ Related Functions
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-basedforusingdirectory_iterator. literally just so you can writefor (auto &e : it)and feel like a genius. π§directory_iterator end (directory_iterator) noexceptβ return a past-the-enddirectory_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
- centos-stream 9: libstdc++-docs 11.5.0-16.el9 Β· GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms