Skip to content

Search topics & cppreference

Search all study topics, concept maps, and 6,587 C++ and C reference pages.

std::basic_stacktrace<Allocator>::empty

Checks if the stacktrace has no stacktrace entries.

NotebookLM
bool empty() const noexcept;
(since C++23)

Checks if the stacktrace has no stacktrace entries.

Parameters

(none)

Return value

true if the stacktrace is empty, false otherwise.

Complexity

Constant.

Example

example.cpp
#include <stacktrace>
#include <iostream>
 
int main()
{
    std::cout << std::boolalpha;
    std::stacktrace bktr;
    std::cout << "Initially, bktr.empty(): " << bktr.empty() << '\n';
 
    bktr = std::stacktrace::current();
    std::cout << "After getting entries, bktr.empty(): " << bktr.empty() << '\n';
}
Possible output
Initially, bktr.empty(): true
After getting entries, bktr.empty(): false

See also

returns the number of stacktrace entries
(public member function)

Content from this page on cppreference.com, licensed under CC-BY-SA 3.0 and GFDL. Modified: restyled, site navigation removed, code windows added. Offline snapshot of 9 February 2025.