std::filesy...m::path::end(3)
π
std::filesy...m::path::end(3) β bestie edition π¦
okay so this is the std::filesy...m::path::end(3) page from the C++ Standard Libary manual (yes, that's how the header spells it, bestie π). It's the begin/end iterator moment for std::filesystem::path, and it's been iconic since C++17 β¨.
π NAME π
std::filesystem::path::begin,std::filesystem::path::end - std::filesystem::path::begin,std::filesystem::path::end
like, that's the whole name line, and the description is literally the same string again. periodt.
π¦ Synopsis π¦
iterator begin() const; (1) (since C++17)
iterator end() const; (2) (since C++17)
- Returns an iterator to the first element of the path. If the path is empty, the returned iterator is equal to
end(). - Returns an iterator one past the last element of the path. Dereferencing this iterator is undefined behavior.
π¨ bestie, dereferencing this iterator is undefined behavior. That's the end() iterator, so don't do it. No cap. π
The sequence denoted by this pair of iterators consists of the following:
root-name(if any).root-directory(if any).- Sequence of file-names, omitting any directory separators.
- If there is a directory separator after the last file-name in the path, the last element before the end iterator is an empty element.
πΈ Parameters πΈ
(none)
β¨ Return value β¨
- Iterator to the first element of the path.
- Iterator one past the end of the path
π Exceptions π
May throw implementation-defined exceptions.
π Example π
the page literally says // Run this code, so here's the code, bestie:
#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';
}
π 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" β
okay bye ily π source/version: http://cppreference.com; date: 2024.06.10; page: std::filesy...m::path::end(3).
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms