命名空间
变体
操作

std::experimental::source_location::file_name

来自 cppreference.cn
 
 
实验性
技术规范
文件系统库 (filesystem TS)
库基础 (library fundamentals TS)
库基础 2 (library fundamentals TS v2)
库基础 3 (library fundamentals TS v3)
并行扩展 (parallelism TS)
并行扩展 2 (parallelism TS v2)
并发扩展 (concurrency TS)
并发扩展 2 (concurrency TS v2)
概念 (concepts TS)
范围 (ranges TS)
反射 (reflection TS)
数学特殊函数 (special functions TR)
实验性非 TS
模式匹配
线性代数
std::execution
契约
2D 图形
 
 
 
constexpr const char* file_name() const noexcept;
(库基础 TS v2)

返回此对象表示的当前源文件的名称,表示为 null 结尾的字节字符串。

目录

[编辑] 参数

(无)

[编辑] 返回值

此对象表示的当前源文件的名称,表示为 null 结尾的字节字符串。

[编辑] 示例

#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();
}

可能的输出

File: main.cpp

[编辑] 参见

返回由此对象表示的行号
(公共成员函数) [编辑]
返回由此对象表示的列号
(公共成员函数) [编辑]
返回由此对象表示的函数的名称(如果有)
(公共成员函数) [编辑]
C++ 文档 关于 文件名和行信息