std::experi...lative_path(3)
π¦ std::experi...lative_path(3) π¦
okay bestie, welcome to the C++ Standard Libary manual page for std::experimental::filesystem::path::relative_path β yes the header says "Libary", we're not fixing it, we're honoring it π
β¨ NAME β¨
std::experimental::filesystem::path::relative_path β literally the same thing twice, because that's how NAME sections roll, and honestly? iconic. π
β¨ SYNOPSIS β¨
path relative_path() const; (filesystem TS)
so the whole vibe here: it returns the path relative to root path. and if *this is an empty path? you get an empty path right back. no drama, no cap. π«Ά
β¨ PARAMETERS β¨
none. zero. nada. it takes nothing, she just works. π
β¨ RETURN VALUE β¨
Path relative to the root path. that's the whole thing. that's the gift. πΈ
β¨ EXCEPTIONS β¨
β οΈ may throw implementation-defined exceptions β so like, it might throw, but exactly which ones is between your implementation and the compiler gods. π
β¨ EXAMPLE β¨
run this code, bestie, it's giving "decomposition reveal" π₯
// Run this code
#include <experimental/filesystem>
#include <iostream>
namespace fs = std::experimental::filesystem;
int main()
{
fs::path p = fs::current_path();
std::cout << "The current path " << p << " decomposes into:\n"
<< "root-path " << p.root_path() << '\n'
<< "relative path " << p.relative_path() << '\n';
}
π possible output
The current path "C:\Users\abcdef\Local Settings\temp" decomposes into:
root-path "C:\"
relative path "Users\abcdef\Local Settings\temp"
look at her go ππ
π SEE ALSO π
root_nameβ returns the root-name of the path, if present (public member function) βroot_directoryβ returns the root directory of the path, if present (public member function) πroot_pathβ returns the root path of the path, if present (public member function) π¦
all three: "if present" β because sometimes the path just doesn't have one and that's valid, iykyk π
π CATEGORY π
- Noindexed pages
and that's the page!! sourced from http://cppreference.com, version 2024.06.10 β mwah, go decompose some paths, ily, bye π§π
π¦ 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