std::polymorphic<T, Allocator>::operator=
来自cppreference.com
< cpp | memory | polymorphic
constexpr polymorphic& operator=( const polymorphic& other ); |
(1) | (C++26 起) |
constexpr polymorphic& operator=( polymorphic&& other ) noexcept(/* 见下文 */); |
(2) | (C++26 起) |
将 *this 的内容替换成 other 的内容。
设 traits 为 std::allocator_traits<Allocator>:
1) 如果 std::addressof(other) == this 是 true,那么什么也不做。否则,设 need_update 为 traits::propagate_on_container_copy_assignment::value:
如果
T 是不完整类型,那么程序非良构。2) 如果 std::addressof(other) == this 是 true,那么什么也不做。否则,设 need_update 为 traits::propagate_on_container_move_assignment::value:
如果满足以下所有条件,那么程序非良构:
- std::allocator_traits<Allocator>::is_always_equal::value 是 false。
-
T是不完整类型。
参数
| other | - | 拥有的值(如果存在)用于赋值的另一 polymorphic 对象
|
返回值
*this
异常
1) 如果抛出了异常,那么 *this 不会受到影响。
2) 如果抛出了异常,那么 *this 和 other 不会受到影响。
noexcept 说明:
noexcept(std::allocator_traits<Allocator>::
propagate_on_container_move_assignment::value
示例
| 本节未完成 原因:暂无示例 |