std::basic_stacktrace<Allocator>:: operator=
From zh.cppreference.net
<
cpp
|
utility
|
basic stacktrace
|
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 在分配失败时可能被设为空值,若实现强化了异常规范。
目录参数
返回值* 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))之后,除非因分配器不兼容而强制进行逐元素移动赋值,否则原本引用 示例
参阅
|