std::basic_stacktrace<Allocator>::empty

From cppreference.com
 
 
Utilities library
General utilities
Date and time
Function objects
Formatting library (C++20)
(C++11)
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)(C++20)(C++20)   
(C++20)
Swap and type operations
(C++14)
(C++11)

(C++11)
(C++11)
(C++17)
Common vocabulary types
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++17)

Elementary string conversions
(C++17)
(C++17)
 
 
 
[[nodiscard]] 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

#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

(C++23)
returns the number of stacktrace entries
(public member function)