std::experimental::source_location:: function_name
From cppreference.net
<
cpp
|
experimental
|
source location
|
constexpr
const
char
*
function_name
(
)
const
noexcept
;
|
(라이브러리 펀더멘털 TS v2) | |
이 객체가 나타내는 위치와 연관된 함수의 이름을 반환합니다(있는 경우).
목차 |
매개변수
(없음)
반환값
이 객체가 함수 본문 내의 위치를 나타내는 경우, 함수 이름에 해당하는 구현 정의(implementation-defined) 널 종료 바이트 문자열을 반환합니다.
그렇지 않으면 빈 문자열이 반환됩니다.
예제
다음 예제는
std::source_location::function_name()
을 사용하여
함수, 생성자, 소멸자, 또는 오버로드된
operator()
의 이름을
출력하는 방법을 보여줍니다.
이 코드 실행
#include <experimental/source_location> #include <iostream> #include <string_view> inline void function_name( const std::string_view signature = "()", const std::experimental::source_location& location = std::experimental::source_location::current()) { std::cout << location.function_name() // <- name of the caller! << signature << '\n'; } void foo() { function_name(); } struct S { S() { function_name(); } S(int) { function_name("(int)"); } S& operator=(S const&) { function_name("(const S&)"); return *this; } S& operator=(S&&) { function_name("(S&&)"); return *this; } ~S() { function_name(); } }; int main() { foo(); S p; S q{42}; p = q; p = std::move(q); }
가능한 출력:
foo() S() S(int) operator=(const S&) operator=(S&&) ~S() ~S()
참고 항목
|
이 객체가 나타내는 줄 번호를 반환합니다
(public member function) |
|
|
이 객체가 나타내는 열 번호를 반환합니다
(public member function) |
|
|
이 객체가 나타내는 파일 이름을 반환합니다
(public member function) |
|
|
C++ documentation
for
파일 이름 및 줄 정보
|
|