名稱空間
變體
操作

std::experimental::source_location::file_name

來自 cppreference.com
 
 
實驗性
技術規範
檔案系統庫 (檔案系統 TS)
庫基礎 (庫基礎 TS)
庫基礎 2 (庫基礎 TS v2)
庫基礎 3 (庫基礎 TS v3)
並行性擴充套件 (並行性 TS)
並行性擴充套件 2 (並行性 TS v2)
併發性擴充套件 (併發性 TS)
併發擴充套件 2 (concurrency TS v2)
概念 (概念 TS)
範圍 (範圍 TS)
反射 (反射 TS)
數學特殊函式 (特殊函式 TR)
實驗性非 TS
模式匹配
線性代數
std::execution
契約
2D 圖形
 
 
 
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++ 文件,關於 檔名與行資訊