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

Returns an iterator to the first entry of the basic_stacktrace.

# Declarations

const_iterator begin() const noexcept;

(since C++23)

const_iterator cbegin() const noexcept;

(since C++23)

# Return value

Iterator to the first entry.

# Example

#include <algorithm>
#include <iostream>
#include <stacktrace>
 
int main()
{
    auto trace       = std::stacktrace::current();
    auto empty_trace = std::stacktrace{};
 
    // Print stacktrace.
    std::for_each(trace.begin(), trace.end(),
                  [](const auto& f) { std::cout << f << '\n'; });
 
    if (empty_trace.begin() == empty_trace.end())
        std::cout << "stacktrace 'empty_trace' is indeed empty.\n";
}

# See also