Namespaces
Variants

std::basic_stacktrace<Allocator>:: begin, std::basic_stacktrace<Allocator>:: cbegin

From cppreference.net
const_iterator begin ( ) const noexcept ;
(1) (C++23 이후)
const_iterator cbegin ( ) const noexcept ;
(2) (C++23 이후)

basic_stacktrace 의 첫 번째 항목에 대한 반복자를 반환합니다.

만약 basic_stacktrace 가 비어 있으면, 반환된 반복자는 end() 와 같습니다.

range-begin-end.svg

목차

매개변수

(없음)

반환값

첫 번째 항목에 대한 반복자.

복잡도

상수.

예제

#include <algorithm>
#include <iostream>
#include <stacktrace>
int main()
{
    auto trace       = std::stacktrace::current();
    auto empty_trace = std::stacktrace{};
    // 스택 트레이스 출력
    std::for_each(trace.begin(), trace.end(),
                  [](const auto& f) { std::cout << f << '\n'; });
    if (empty_trace.begin() == empty_trace.end())
        std::cout << "스택 트레이스 'empty_trace'는 실제로 비어 있습니다.\n";
}

가능한 출력:

0x0000000000402BA8 in ./prog.exe
__libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
0x0000000000402A29 in ./prog.exe
stacktrace 'empty_trace' is indeed empty.

참고 항목

끝을 가리키는 반복자를 반환합니다
(public member function)