std::experi...n::file_name(3)
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
- 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