Namespaces
Variants

std::basic_stacktrace<Allocator>:: operator=

From cppreference.net
basic_stacktrace & operator = ( const basic_stacktrace & other ) ;
(1) (自 C++23 起)
basic_stacktrace & operator = ( basic_stacktrace && other )
noexcept ( /* 见下文 */ ) ;
(2) (自 C++23 起)

替换 basic_stacktrace 的内容。

1) 复制赋值运算符。将当前对象内容替换为 other 内容的副本。
std:: allocator_traits < allocator_type > :: propagate_on_container_copy_assignment :: value true ,则 * this 的分配器将被替换为 other 分配器的副本。若赋值后 * this 的分配器与其旧值比较不相等,则旧分配器将用于释放内存,随后新分配器会在复制条目前用于分配内存。否则, * this 所拥有的内存在可能时会被复用。
2) 移动赋值运算符。使用移动语义将内容替换为 other 的内容(即将 other 中的数据移动到 * this 中)。此后 other 处于有效但未指定的状态。
std:: allocator_traits < allocator_type > :: propagate_on_container_move_assignment :: value true ,则 * this 的分配器将被替换为 other 分配器的副本。若该值为 false * this other 的分配器比较不相等,则 * this 无法接管 other 所占用的内存,必须逐项进行赋值操作,并根据需要使用其自身的分配器分配额外内存。

在任何情况下,原本属于 * this 的堆栈跟踪条目可能被销毁,也可能通过逐元素赋值被替换。

* this 在分配失败时可能被设为空值,若实现强化了异常规范。

目录

参数

其他 - 用作源的另一个 basic_stacktrace

返回值

* this

复杂度

1) * this other 的大小成线性关系。
2) * this 的大小呈线性关系,除非分配器不相等且不传播,此时与 * this other 的大小之和呈线性关系。

异常

1) 可能抛出实现定义的异常。
2)
noexcept 规范:
noexcept ( std:: allocator_traits < Allocator > :: propagate_on_container_move_assignment :: value
|| std:: allocator_traits < Allocator > :: is_always_equal :: value )

注释

在容器移动赋值操作后(重载 ( 2 ) ),除非因分配器不兼容而强制进行逐元素移动赋值,否则指向 other 的引用、指针和迭代器(除尾后迭代器外)仍然有效,但此时这些引用、指针和迭代器将指向位于 * this 中的元素。当前标准通过 [container.reqmts]/67 中的总体声明提供此保证,同时正在通过 LWG 2321 提案考虑提供更直接的保证。

示例

参阅

创建新的 basic_stacktrace
(公开成员函数)