Namespaces
Variants
Views
Actions

std::operator<<(std::stacktrace_entry)

From cppreference.com
 
 
Utilities library
General utilities
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)

Stacktrace
 
 
Defined in header <stacktrace>
template< class CharT, class Traits >

std::basic_ostream<CharT, Traits>&

    operator<<( std::basic_ostream<CharT, Traits>& os, const std::stacktrace_entry& f );
(since C++23)

Inserts the description of f into the output stream os. Equivalent to return os << std::to_string(f);.

Contents

[edit] Parameters

os - an output stream
f - a stacktrace_entry whose description is to be inserted

[edit] Return value

os.

[edit] Exceptions

May throw implementation-defined exceptions.

[edit] Notes

Since std::string can only be outputted by std::ostream (not by e.g. std::wostream), it is effectively required that os be of type std::ostream&.

[edit] Example

#include <stacktrace>
#include <iostream>
 
int main()
{
    for (const auto &f : std::stacktrace::current())
        std::cout << f << '\n';
}

Possible output:

0x0000000000402AA7 in ./prog.exe
__libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
0x00000000004029B9 in ./prog.exe

[edit] See also

performs stream output of basic_stracktrace
(function template) [edit]