std::indirect<T, Allocator>::operator=
来自cppreference.com
| (1) | (C++26 起) | |
| (2) | (C++26 起) | |
| (3) | (C++26 起) | |
将 *this 的内容替换成 other 的内容或 value。
设 traits 为 std::allocator_traits<Allocator>:
1) 如果
std::addressof(other) == this 是 true,那么什么也不做。否则,设 need_update 为 traits::propagate_on_container_copy_assignment::value:
如果
std::is_copy_assignable_v<T> && std::is_copy_constructible_v<T> 是 false ,那么程序非良构。2) 如果
std::addressof(other) == this 是 true,那么什么也不做。否则,设 need_update 为 traits::propagate_on_container_move_assignment::value:
如果
std::is_copy_constructible_v<T> 是 false ,那么程序非良构。 此重载只有在满足以下所有条件时才会参与重载决议:
std::is_same_v<std::remove_cvref_t<U>, std::indirect>是false。std::is_constructible_v<T, U>是true。std::is_assignable_v<T&, U>是true。
参数
| other | - | 拥有的值(如果存在)用于赋值的另一 indirect 对象
|
| value | - | 用来赋值或者构造拥有的对象的值 |
返回值
*this
异常
1) 如果抛出了异常,那么
this->valueless_after_move() 的结果保持不变。 如果在调用
T 的选中的复制构造函数的过程中抛出了异常,那么没有效果。2) 如果抛出了异常,那么
*this 和 other 不会受到影响。noexcept 说明:
noexcept(std::allocator_traits<Allocator>::
propagate_on_container_move_assignment::value
|| std::allocator_traits<Allocator>::is_always_equal::value)
示例
| 本节未完成 原因:暂无示例 |