std::list<T,Allocator>::assign
来自cppreference.com
| void assign( size_type count, const T& value ); |
(1) | |
| template< class InputIt > void assign( InputIt first, InputIt last ); |
(2) | |
| void assign( std::initializer_list<T> ilist ); |
(3) | (C++11 起) |
替换容器的内容。
1) 以
count 份 value 的副本替换内容。2) 以范围
[first, last) 中元素的副本替换内容。若任一参数是指向 *this 中的迭代器则行为未定义。
|
若 |
(C++11 前) |
|
此重载仅若 |
(C++11 起) |
3) 以来自 initializer_list
ilist 的元素替换内容。所有指向容器元素的迭代器、指针及引用均被非法化。
参数
| count | - | 容器的新大小 |
| value | - | 用以初始化容器元素的值 |
| first, last | - | 复制来源元素的范围 |
| ilist | - | 复制值来源的 initializer_list |
复杂度
1) 与
count 成线性2) 与
first 和 last 间的距离成线性3) 与 ilist.size() 成线性
示例
参阅
构造 list (公开成员函数) |