std::basic_stacktrace<Allocator>::size - cppreference.com

From cppreference.com

size_typesize()constnoexcept;(since C++23)Returns the number of entries in the stacktrace.

Parameters

(none)

Return value

The number of entries in the stacktrace.

Complexity

Constant.

Example

The following code uses size to display the number of entries in the current stacktrace:

Run this code

#include<stacktrace>#include<iostream>intmain(){autotrace=std::stacktrace::current();std::cout<<"trace contains "<<trace.size()<<" entries.\n";}Possible output:

trace contains 3 entries. See also

checks whether the basic_stacktrace is empty
(public member function)

[edit]

returns the maximum possible number of stacktrace entries
(public member function)

[edit]