std::basic_...race::empty(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

🌸 NAME 🌸

std::basic_stacktrace::empty β€” okay bestie, this is the std::basic_stacktrace::empty(3) page, all about the std::basic_stacktrace::empty member function, straight from the C++ Standard Libary manual, and it's here to answer one very specific question: is your stacktrace empty? No cap. πŸ’…

πŸ¦‹ Synopsis πŸ¦‹

[[nodiscard]] bool empty() const noexcept;

✨ since C++23 ✨

It checks if the stacktrace has no stacktrace entries.

πŸŽ€ Parameters πŸŽ€

  • (none) β€” literally no parameters, bestie. Zero. Nada. 🫢

πŸ’– Return value πŸ’–

true if the stacktrace is empty, false otherwise. That's the whole answer, periodt.

⭐ Complexity ⭐

Constant. Yep β€” constant energy, no dramatic scaling arc. 🌈

πŸ”₯ Example πŸ”₯

// Run this code

#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
it's giving "empty at first, then full of entries" and honestly? iconic. πŸ’…

πŸ‘‘ See also πŸ‘‘

  • size β€” returns the number of stacktrace entries (public member function).

πŸ’– source/version: http://cppreference.com Β· date: 2024.06.10 πŸ’–

πŸ“¦ where this page comes from