std::source_location:: line
From cppreference.net
<
cpp
|
utility
|
source location
C++
Utilities library
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::source_location
| Member functions | ||||
| Creation | ||||
| Field access | ||||
|
source_location::line
|
||||
|
constexpr
std::
uint_least32_t
line
(
)
const
noexcept
;
|
(C++20부터) | |
이 객체가 나타내는 줄 번호를 반환합니다.
목차 |
매개변수
(없음)
반환값
이 객체가 나타내는 줄 번호입니다.
구현체는 줄 번호를 알 수 없는 경우
0
을 반환하는 것이 권장됩니다.
예제
이 코드 실행
#include <iostream> #include <string_view> #include <source_location> inline void cur_line( const std::string_view message = "", const std::source_location& location = std::source_location::current()) { std::cout << location.line() // <- the line # of a call site << ") " << message; } int main() { cur_line("++\n"); cur_line(); std::cout << "Hello,\n"; cur_line(); std::cout << "C++20!\n"; cur_line("--\n"); }
출력:
17) ++ 18) Hello, 19) C++20! 20) --
참고 항목
|
이 객체가 나타내는 열 번호를 반환합니다
(public member function) |
|
|
이 객체가 나타내는 파일 이름을 반환합니다
(public member function) |
|
|
이 객체가 나타내는 함수의 이름을 반환합니다(있는 경우)
(public member function) |
|
stacktrace_entry
가 나타내는 평가와 어휘적으로 관련된 줄 번호를 가져옵니다
(
std::stacktrace_entry
의 public member function)
|
|
| 파일 이름과 줄 정보 | |