boostorg / stacktrace

C++ library for storing and printing backtraces.
https://boost.org/libs/stacktrace
433 stars 74 forks source link

Fast conversion of stacktraces to std::string #57

Closed antoshkka1 closed 6 years ago

antoshkka1 commented 6 years ago
/// Outputs stacktrace in a human readable format to std::string; unsafe to use in async handlers.
template <class Allocator>
std::string to_string(const basic_stacktrace<Allocator>& bt) {
    if (bt) {
        return boost::stacktrace::detail::to_string(&bt.as_vector()[0], bt.size());
    } else {
        return std::string();
    }
}