std::filesy...::root_path(3)

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

🌸 NAME 🌸

The manual page std::filesy...::root_path(3) is from the C++ Standard Libary (their spelling, not mine πŸ’€), and it’s all about std::filesystem::path::root_path. The original name line is literally std::filesystem::path::root_path - std::filesystem::path::root_path, which is iconic in a deeply unhinged way. πŸ’…

✨ Synopsis ✨

path root_path() const;  (since C++17)

Returns the root path of the path. If the path does not include root path, returns path().

Effectively returns root_name() / root_directory().

🫢 Parameters 🫢

(none) β€” zero, nada, no arguments. It’s giving low-maintenance icon. ✨

πŸŽ€ Return value πŸŽ€

The root path of the path. That’s the whole vibe. πŸŽ€

😭 Exceptions 😭

May throw implementation-defined exceptions. So like… your implementation gets to decide the drama level, bestie. 😭

πŸ’» Example πŸ’»

The page says // Run this code right before the snippet, so here’s the exact code:

        #include <filesystem>
        #include <iostream>
        namespace fs = std::filesystem;

        int main()
        {
            std::cout << "Current root path is: " <<
       fs::current_path().root_path() << '\n';
        }

Possible output:

Current root path is: "C:\"

πŸ‘€ 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)

That’s the tea from http://cppreference.com, version/date 2024.06.10, page std::filesy...::root_path(3) β€” periodt. πŸ’–βœ¨

πŸ“¦ where this page comes from