std::filesy...error::path2(3)
Okay so this is the std::filesy...error::path2(3) page from the C++ Standard Libary manual, and it covers both path1 and path2 like the iconic duo they are. Bestie, itβs giving βtwo path functions, one manpage,β and weβre keeping every detail, no cap.
π NAME π
std::filesystem::filesystem_error::path1,std::filesystem::filesystem_error::path2β yes, thatβs literally the name, comma and all, no space after it. The original lists it twice, so weβre honoring the double-listing energy. π
β¨ Synopsis β¨
const std::filesystem::path& path1() const noexcept; (since C++17)
const std::filesystem::path& path2() const noexcept; (since C++17)
Both are noexcept and both show up since C++17, periodt. The vibe check says: they return the paths that were stored in the exception object. π¦
πΈ Parameters πΈ
(none) β literally zero parameters, not a single one, bestie. π«Ά
π Return value π
References to the copy of the path parameters stored by the constructor. Lowkey thatβs the whole return-value vibe: references to the copies the constructor stored, ngl. β¨
π¦ Example π¦
// Run this code β yes bestie, run it, fr fr:
#include <cstdio>
#include <filesystem>
#include <iostream>
int main()
{
const std::filesystem::path old_p{std::tmpnam(nullptr)},
new_p{std::tmpnam(nullptr)};
try {
std::filesystem::rename(old_p, new_p); // throws since old_p
does not exist
}
catch(std::filesystem::filesystem_error const& ex) {
std::cout
<< "what(): " << ex.what() << '\n'
<< "path1(): " << ex.path1() << '\n'
<< "path2(): " << ex.path2() << '\n';
}
}
π Possible output π
Possible output, and it might look exactly like this β iykyk:
what(): filesystem error: cannot rename: No such file or directory
[/tmp/fileIzzRLB] [/tmp/fileiUDWlV]
path1(): "/tmp/fileIzzRLB"
path2(): "/tmp/fileiUDWlV"
Source/version/date check: http://cppreference.com, 2024.06.10, page std::filesy...error::path2(3) β thatβs the cute little footer folded into a sign-off, mwah ππ
π¦ 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