std::experimental::source_location::line
來自 cppreference.com
< cpp | experimental | source_location
constexpr std::uint_least32_t line() const noexcept; |
(庫基礎 TS v2) | |
返回此物件表示的行號。
目錄 |
[編輯] 引數
(無)
[編輯] 返回值
此物件表示的行號。
[編輯] 示例
執行此程式碼
#include <experimental/source_location> #include <iostream> #include <string_view> using std::experimental::source_location; inline void cur_line( const std::string_view message = "", const source_location& location = source_location::current()) { std::cout << location.line() // <- the call-site line # << ") " << message; } int main() { cur_line("++" "\n"); cur_line(); std::cout << "Hello," "\n"; cur_line(); std::cout << "C++20!" "\n"; cur_line("--" "\n"); }
輸出
18) ++ 19) Hello, 20) C++20! 21) --
[編輯] 參閱
返回此物件表示的列號 (public 成員函式) | |
返回此物件表示的檔名 (public 成員函式) | |
返回此物件表示的函式名(如果有) (public 成員函式) | |
C++ 文件,關於 檔名與行資訊
|