std:: to_string
From cppreference.net
<
cpp
|
utility
|
basic stacktrace
C++
Diagnostics library
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::basic_stacktrace
| Member functions | ||||
| Iterators | ||||
| Capacity | ||||
| Element access | ||||
| Modifiers | ||||
| Non-member functions | ||||
|
to_string
(std::basic_stacktrace)
|
||||
| Helper classes | ||||
|
定义于头文件
<stacktrace>
|
||
|
template
<
class
Allocator
>
std:: string to_string ( const std:: basic_stacktrace < Allocator > & st ) ; |
(C++23 起) | |
返回一个包含
st
描述信息的字符串。
basic_stacktrace
的描述通常包含其条目的说明,但行数不要求与
size()
相等。
目录 |
参数
| st | - |
要返回其描述的
basic_stacktrace
对象
|
返回值
一个包含
st
描述信息的字符串。
异常
可能抛出实现定义的异常。
注释
此函数未提供自定义分配器支持,因为实现通常需要平台特定的内存分配、系统调用以及大量CPU密集型工作,而自定义分配器对此函数并无助益,因为平台特定操作所耗时间比内存分配高出一个数量级。
示例
运行此代码
#include <stacktrace> #include <string> #include <iostream> int main() { auto trace = std::stacktrace::current(); std::cout << std::to_string(trace) << '\n'; }
可能的输出:
0# 0x0000000000402D97 in ./prog.exe 1# __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6 2# 0x0000000000402CA9 in ./prog.exe
参见
|
(C++23)
|
返回包含
stacktrace_entry
描述信息的字符串
(函数) |