std::experi...m::path::end(3)
β¨ NAME β¨
okay so bestie, gather round, because this page is about std::experimental::filesystem::path::begin,std::experimental::filesystem::path::end β no wait, I'm not done, the manual then repeats the entire thing again as the description: std::experimental::filesystem::path::begin,std::experimental::filesystem::path::end. yes, twice. the manual said "why say it once when you could say it twice" and honestly? iconic behavior π
this is the std::experi...m::path::end(3) page of the C++ Standard Libary manual β that ellipsis in the title is carrying the whole team, iykyk π
π Synopsis π
iterator begin() const; (1) (filesystem TS)
iterator end() const; (2) (filesystem TS)
here's the tea, numbered and everything π₯
- Returns an iterator to the first element of the path. and bestie, listen β if the path is empty, the iterator it hands you is equal to
end(). empty path = begin meets end, they're the same iterator, it's giving soulmate energy π«Ά - Returns an iterator one past the last element of the path. and dereferencing this iterator is undefined behavior β do NOT touch it, do NOT peek at it, do NOT
*itit. it's the velvet rope at the end of the club, you look at it and that's it π
the sequence denoted by this pair of iterators consists of the following, in order, no cap:
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 a fictitious dot file name. (yes. a fake
.β it's not even real, it's just there for the vibes π§)
πΈ Parameters πΈ
(none)
that's it. that's the section. nothing to see here, no arguments were invited to this party π
π Return value π
- Iterator to the first element of the path.
- Iterator one past the end of the path.
π¦ Exceptions π¦
May throw implementation-defined exceptions. so likeβ¦ your implementation decides, and you just have to live with that uncertainty, bestie π
π Example π
// Run this code
#include <experimental/filesystem>
#include <iostream>
namespace fs = std::experimental::filesystem;
int main()
{
fs::path p = "C:\\users\\abcdef\\AppData\\Local\\Temp\\";
std::cout << "Examining the path " << p << " through iterators gives\n";
for (auto& e : p)
std::cout << e << '\n';
}
look at her go β a ranged for loop straight over a fs::path, no .begin()/.end() written out, the compiler does it silently like a main character π
β Output β
Examining the path "C:\users\abcdef\AppData\Local\Temp\" through iterators gives
"C:"
"/"
"users"
"abcdef"
"AppData"
"Local"
"Temp"
"."
see that last .? that's the fictitious dot file name from item 4, showing up to say hi π«Ά and "C:" and "/" are the root-name and root-directory doing their thing. the way this path decomposes into little piecesβ¦ obsessed π
π Category: π
* Noindexed pages
that's a wrap, bestie! this lil masterpiece was served fresh from http://cppreference.com on 2024.06.10 β go iterate over some paths responsibly, and remember: the end iterator is a look-don't-touch situation β¨π
π¦ 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