名稱空間
變體
操作

std::source_location::file_name

來自 cppreference.com
 
 
 
 
constexpr const char* file_name() const noexcept;
(C++20 起)

返回此物件表示的當前原始檔名稱,表示為以空字元結尾的位元組字串。

目錄

[編輯] 引數

(無)

[編輯] 返回值

此物件表示的當前原始檔名稱,表示為以空字元結尾的位元組字串。

[編輯] 示例

#include <iostream>
#include <source_location>
 
void print_this_file_name(
    std::source_location location = std::source_location::current())
{
    // Name of file that contains the call site of this function.
    std::cout << "File: " << location.file_name() << '\n';
}
 
int main()
{
#line 1 "cppreference.cpp"
    print_this_file_name();
}

輸出

File: cppreference.cpp

[編輯] 參閱

返回此物件表示的行號
(公共成員函式) [編輯]
返回此物件表示的列號
(公共成員函式) [編輯]
返回此物件表示的函式名(如果有)
(公共成員函式) [編輯]
獲取詞法包含其求值由 stacktrace_entry 表示的表示式或語句的原始檔名稱
(std::stacktrace_entry 的公共成員函式) [編輯]
檔名和行資訊