std::experimental::source_location::file_name
来自 cppreference.cn
< cpp | experimental | source_location
constexpr const char* file_name() const noexcept; |
(库基础 TS v2) | |
返回此对象所表示的当前源文件名称,以空终止字节串表示。
目录 |
[编辑] 参数
(无)
[编辑] 返回值
此对象所表示的当前源文件名称,以空终止字节串表示。
[编辑] 示例
运行此代码
#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
[编辑] 参阅
返回此对象表示的行号 (public member function) | |
返回此对象表示的列号 (public member function) | |
返回此对象表示的函数名(如果有) (public member function) | |
C++ 文档,关于 文件名与行信息
|