std::filesystem::path::begin, std::filesystem::path::end

  1. Returns an iterator to the first element of the path. If the path is empty, the returned iterator is equal to end().

# Declarations

iterator begin() const;

(since C++17)

iterator end() const;

(since C++17)

# Example

#include <filesystem>
#include <iostream>
namespace fs = std::filesystem;
 
int main()
{
    const fs::path p = 
#   ifdef _WIN32
        "C:\\users\\abcdef\\AppData\\Local\\Temp\\";
#   else
        "/home/user/.config/Cppcheck/Cppcheck-GUI.conf";
#   endif
    std::cout << "Examining the path " << p << " through iterators gives\n";
    for (auto it = p.begin(); it != p.end(); ++it)
        std::cout << *it << " │ ";
    std::cout << '\n';
}