size_type size() const noexcept; | (since C++23) |
Returns the number of entries in the stacktrace.
(none).
The number of entries in the stacktrace.
Constant.
The following code uses size
to display the number of entries in the current stacktrace:
#include <stacktrace> #include <iostream> int main() { auto trace = std::stacktrace::current(); std::cout << "trace contains " << trace.size() << " entries.\n"; }
Possible output:
trace contains 3 entries.
(C++23) | checks whether the basic_stacktrace is empty (public member function) |
(C++23) | returns the maximum possible number of stacktrace entries (public member function) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/utility/basic_stacktrace/size