Namespaces
Variants

std::source_location:: file_name

From cppreference.net
Utilities library
constexpr const char * file_name ( ) const noexcept ;
(C++20부터)

이 객체가 나타내는 현재 소스 파일의 이름을 null 종료 바이트 문자열로 반환합니다.

목차

매개변수

(없음)

반환값

이 객체가 나타내는 현재 소스 파일의 이름으로, 널 종료 바이트 문자열로 표현됩니다.

예제

#include <iostream>
#include <source_location>
void print_this_file_name(
    std::source_location location = std::source_location::current())
{
    // 이 함수의 호출 위치를 포함하는 파일 이름
    std::cout << "File: " << location.file_name() << '\n';
}
int main()
{
#line 1 "cppreference.cpp"
    print_this_file_name();
}

출력:

File: cppreference.cpp

참고 항목

이 객체가 나타내는 줄 번호를 반환합니다
(public member function)
이 객체가 나타내는 열 번호를 반환합니다
(public member function)
이 객체가 나타내는 함수의 이름을 반환합니다 (있는 경우)
(public member function)
평가가 stacktrace_entry 로 나타나는 표현식이나 문장을 어휘적으로 포함하는 소스 파일의 이름을 가져옵니다
( std::stacktrace_entry 의 public member function)
파일 이름과 줄 정보