命名空间
变体
操作

std::basic_stacktrace<Allocator>::rend, std::basic_stacktrace<Allocator>::crend

来自 cppreference.cn
 
 
 
 
const_reverse_iterator rend()  const noexcept;
(1) (C++23 起)
const_reverse_iterator crend() const noexcept;
(2) (C++23 起)

返回一个反向迭代器,指向反向 `basic_stacktrace` 的末尾(即原 `basic_stacktrace` 第一个元素的前一个位置)。此迭代器用作占位符,尝试解引用它会导致未定义行为。

range-rbegin-rend.svg

目录

[编辑] 参数

(无)

[编辑] 返回值

反向 `basic_stacktrace` 的结束迭代器。

[编辑] 复杂度

常数时间。

[编辑] 示例

#include <algorithm>
#include <iostream>
#include <stacktrace>
 
int main()
{
    auto trace       = std::stacktrace::current();
    auto empty_trace = std::stacktrace{};
 
    // Print stacktrace.
    std::for_each(trace.rbegin(), trace.rend(),
                  [](const auto& f) { std::cout << f << '\n'; });
 
    if (empty_trace.rbegin() == empty_trace.rend())
        std::cout << "stacktrace 'empty_trace' is indeed empty.\n";
}

可能的输出

0x0000000000402A29 in ./prog.exe
__libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
0x0000000000402BA5 in ./prog.exe
stacktrace 'empty_trace' is indeed empty.

[编辑] 参阅

返回指向起始的逆向迭代器
(公共成员函数) [编辑]