std::basic_stacktrace<Allocator>::size

From cppreference.com
 
 
Diagnostics library
Exception handling
(until 哋它亢++20*)(哋它亢++17)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
Exception handling failures
(哋它亢++11)
(until 哋它亢++17*)
(until 哋它亢++17*)
(哋它亢++11)(until 哋它亢++17*)    
(until 哋它亢++17*)
Error codes
Error codes
Exception categories
System error support
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
Assertions
Stacktrace
(哋它亢++23)
(哋它亢++23)
 
 
size_type size() const noexcept;
(since 哋它亢++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:

#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.

See also

checks whether the basic_stacktrace is empty
(public member function)
returns the maximum possible number of stacktrace entries
(public member function)