iterator begin() const; | (1) | (since C++17) |
iterator end() const; | (2) | (since C++17) |
end()
.The sequence denoted by this pair of iterators consists of the following:
(none).
May throw implementation-defined exceptions.
#include <iostream> #include <filesystem> 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'; }
Possible output:
--- Windows --- Examining the path "C:\users\abcdef\AppData\Local\Temp\" through iterators gives "C:" │ "/" │ "users" │ "abcdef" │ "AppData" │ "Local" │ "Temp" │ "" │ --- UNIX --- Examining the path "/home/user/.config/Cppcheck/Cppcheck-GUI.conf" through iterators gives "/" │ "home" │ "user" │ ".config" │ "Cppcheck" │ "Cppcheck-GUI.conf" │
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/filesystem/path/begin