std::basic_stacktrace<Allocator>::begin, std::basic_stacktrace<Allocator>::cbegin
From cppreference.com
< cpp | utility | basic stacktrace
| const_iterator begin() const noexcept; |
(1) | (C++23から) |
| const_iterator cbegin() const noexcept; |
(2) | (C++23から) |
basic_stacktraceの最初の要素へのイテレータを返します。
もしbasic_stacktraceが空であれば、返されるイテレータはend()と等しくなります。
目次 |
[edit] パラメータ
(なし)
[edit] 戻り値
最初の要素へのイテレータ。
[edit] 計算量
定数。
[edit] 例
このコードを実行
#include <algorithm> #include <iostream> #include <stacktrace> int main() { auto trace = std::stacktrace::current(); auto empty_trace = std::stacktrace{}; // Print stacktrace. std::for_each(trace.begin(), trace.end(), [](const auto& f) { std::cout << f << '\n'; }); if (empty_trace.begin() == empty_trace.end()) std::cout << "stacktrace 'empty_trace' is indeed empty.\n"; }
実行結果の例
0x0000000000402BA8 in ./prog.exe __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6 0x0000000000402A29 in ./prog.exe stacktrace 'empty_trace' is indeed empty.
[edit] 関連項目
| 末尾へのイテレータを返す (public member function) |