Namespaces
Variants

std::experimental::source_location:: line

From cppreference.net
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 member function)
이 객체가 나타내는 파일 이름을 반환합니다
(public member function)
이 객체가 나타내는 함수의 이름을 반환합니다(있는 경우)
(public member function)
C++ documentation for 파일 이름 및 줄 정보