std::to_string
出自cppreference.com
< cpp | utility | basic stacktrace
在標頭 <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 的描述的字符串 (函數) |