std::experi...n::file_name(3)

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

okay so bestie, welcome to the std::experi...n::file_name(3) page β€” manual name folded in near the top like a little name tag πŸŽ€. The header says C++ Standard Libary (their spelling, not mine πŸ’€), and we're about to make std::experimental::source_location::file_name make sense. no cap.

🌸 NAME 🌸

  • std::experimental::source_location::file_name β€” okay so this is the thing: std::experimental::source_location::file_name. That's the name, and also the name again, because the page literally says it twice. Slay.

✨ Synopsis ✨

constexpr const char* file_name() const noexcept;

library fundamentals TS v2 energy ✨

Returns the name of the current source file represented by this object, represented as a null-terminated byte string. Fr fr, that's the whole vibe.

πŸŽ€ Parameters πŸŽ€

(none) β€” literally none, bestie. No parameters. Zero. Nada. The void. πŸ’…

πŸ’– Return value πŸ’–

The name of the current source file represented by this object, represented as a null-terminated byte string. That's it. That's the return. 🫢

🌟 Example 🌟

// Run this code β€” yes bestie, run it πŸ‘‡

        #include <experimental/source_location>
        #include <iostream>

        inline void print_this_file_name(
            const std::experimental::source_location& location
                = std::experimental::source_location::current())
        {
            // Name of file that contains the call-site of this function.
            std::cout << "File: " << location.file_name() << '\n';
        }

        int main()
        {
            print_this_file_name();
        }

🌈 Possible output 🌈

File: main.cpp

It's giving iconic output. ⭐

πŸ¦‹ See also πŸ¦‹

  • line β€” return the line number represented by this object (public member function)
  • column β€” return the column number represented by this object (public member function)
  • function_name β€” return the name of the function represented by this object, if any (public member function)
  • C++ documentation for Filename and line information β€” the docs, bestie.

Signed, sealed, delivered: source/version is cppreference.com, date is 2024.06.10, and the page is std::experi...n::file_name(3). Mwah, bye bestie πŸ’‹πŸ’–

πŸ“¦ where this page comes from