std::stacktrace_entry — represents a single frame in a stacktrace.
1#include <stacktrace>23void logError() {4 auto st = std::stacktrace::current();56 for (const auto& frame : st) {7 // Description (function name)8 std::cout << frame.description() << "\n";910 // Source file and line11 std::cout << " at " << frame.source_file()12 << ":" << frame.source_line() << "\n";1314 // Column (if available)15 if (frame.source_column() > 0) {16 std::cout << " col " << frame.source_column() << "\n";17 }18 }19}2021// Format individual frame22std::cout << std::format("{}\n", st[0]);2324// Compare frames25if (st[0] == st[1]) { /* Same frame */ }2627// As string28std::string s = std::to_string(st[0]);
Properties: