std::experi...lative_path(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ¦‹ 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