std::experi...y_iterator),(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

🌸 NAME 🌸

okay so bestie, welcome to the C++ Standard Libary manual page for std::experi...y_iterator),(3) β€” yes, the header is truncated like that, we’re keeping the vibe, no cap. The NAME block is literally:

std::experimental::filesystem::begin(directory_iterator), -
std::experimental::filesystem::begin(directory_iterator),

(It really does say begin twice in the NAME block; I’m not fixing it, I’m just reporting it. πŸ’…)


✨ Synopsis ✨

Two functions, both non-member, both filesystem TS, both here to make your range-based for loop era iconic:

directory_iterator begin( directory_iterator iter ); (1) (filesystem TS)
directory_iterator end( const directory_iterator& ); (2) (filesystem TS)
  1. (1) returns iter unchanged.
  2. (2) returns a default-constructed directory_iterator, which serves as the end iterator. The argument is ignored.

These non-member functions enable the use of directory_iterators with range-based for loops. πŸ’–

πŸŽ€ Parameters πŸŽ€

  • iter β€” a directory_iterator.

πŸ¦‹ Return value πŸ¦‹

  1. iter unchanged.
  2. End iterator (default-constructed directory_iterator).

🫢 Exceptions 🫢

The noexcept specification is: noexcept.

That’s it β€” that’s the whole section, and it’s giving unconditionally noexcept energy. The category list backs that up. 🫢

🌈 Example 🌈

The page says // Run this code, so here’s the code, bestie:

        #include <experimental/filesystem>
        #include <fstream>
        #include <iostream>
        namespace fs = std::experimental::filesystem;

        int main()
        {
            fs::create_directories("sandbox/a/b");
            std::ofstream("sandbox/file1.txt");
            std::ofstream("sandbox/file2.txt");
            for (auto& p : fs::directory_iterator("sandbox"))
                std::cout << p << '\n';
            fs::remove_all("sandbox");
        }

⭐ Possible output ⭐

        "sandbox/a"
        "sandbox/file1.txt"
        "sandbox/file2.txt"

πŸ”₯ See also πŸ”₯

  • filesystem::begin(filesystem::recursive_directory_iterator) β€” range-based for loop
  • filesystem::end(filesystem::recursive_directory_iterator) β€” support (function)

πŸ‘‘ Categories πŸ‘‘

  • Noindexed pages
  • unconditionally noexcept

πŸ’€ Hidden categories πŸ’€

  • Pages with unreviewed unconditional noexcept template
  • Pages with unreviewed noexcept template

mwah πŸ’‹ β€” source/version is http://cppreference.com, dated 2024.06.10, page std::experi...y_iterator),(3). stay hydrated and may your directory_iterator always find the end iterator exactly when it should. 🫢✨

πŸ“¦ where this page comes from