Namespaces
Variants
Actions

std::basic_stacktrace<Allocator>::size

From cppreference.com
 
C++
 
Diagnostics library
 
std::basic_stacktrace
size_type size() const noexcept;
(since C++23)

Returns the number of entries in the stacktrace.

Contents

[edit] Parameters

(none)

[edit] Return value

The number of entries in the stacktrace.

[edit] Complexity

Constant.

[edit] 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.

[edit] 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]

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant