Namespaces
Variants

std::experimental::source_location:: file_name

From cppreference.net
constexpr const char * file_name ( ) const noexcept ;
(라이브러리 펀더멘털 TS v2)

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

목차

매개변수

(없음)

반환값

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

예제

#include <experimental/source_location>
#include <iostream>
inline void print_this_file_name(
    const std::experimental::source_location& location
        = std::experimental::source_location::current())
{
    // 이 함수의 호출 지점을 포함하는 파일 이름
    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++ documentation for 파일 이름과 줄 정보