std::multiset<Key,Compare,Allocator>::multiset
multiset();
explicit
multiset(
const
Compare&
comp, |
(1) | |
explicit
multiset(
const
Allocator&
alloc );
|
(1) | (C++11 起) |
(2) | ||
template<
class
InputIt >
multiset(
InputIt first, InputIt
last, |
||
template<
class
InputIt >
multiset(
InputIt first, InputIt
last, |
(C++14 起) | |
multiset(
const
multiset&
other );
|
(3) | |
multiset(
const
multiset&
other, const
Allocator&
alloc );
|
(3) | (C++11 起) |
multiset(
multiset&&
other );
|
(4) | (C++11 起) |
multiset(
multiset&&
other, const
Allocator&
alloc );
|
(4) | (C++11 起) |
(5) | ||
multiset( std::initializer_list<value_type>
init,
const
Compare&
comp =
Compare(), |
(C++11 起) | |
multiset( std::initializer_list<value_type>
init,
const Allocator& ); |
(C++14 起) | |
从各种数据源构造新容器,可选地使用用户提供的分配器 alloc
或比较函数对象 comp
。
[first, last)
的内容。other
的内容副本。
若不提供 |
(C++11 起) |
在用于类模板实参推导时,仅从首个实参推导模板形参
|
(C++23 起) |
other
的内容。若不提供 alloc
,则从属于 other
的分配器移动构造分配器。
在用于类模板实参推导时,仅从首个实参推导模板形参
|
(C++23 起) |
init
的内容。参数
alloc | - | 用于此容器所有内存分配的分配器 |
comp | - | 用于所有关键比较的比较函数对象 |
first, last | - | 复制元素来源的范围 |
other | - | 要用作源以初始化容器元素的另一容器 |
init | - | 用以初始化容器元素的 initializer_list |
类型要求 | ||
-InputIt
必须符合老式输入迭代器
(LegacyInputIterator)
的要求。
|
||
-Compare
必须符合比较
(Compare)
的要求。
|
||
-
Allocator 必须符合分配器
(Allocator)
的要求。
|
复杂度
other
的大小成线性。
alloc
且
alloc !=
other.get_allocator() 则为线性。init
已按照 value_comp()
排序则与 N
成线性
。异常
对 Allocator::allocate
的调用可能抛出。
注解
在容器移动构造(重载 (4))后,指向 other 的引用及迭代器(除了尾迭代器)保持合法,但指代现于 *this 中的元素。当前标准由 [container.requirements.general]/12 中的总括陈述作出此保证,而 LWG 问题 2321 正在考虑更严格的保证。
尽管在 C++23 前未正式要求,一些实现已经在较早的模式中将 Allocator
放入非推导语境。
示例
本节未完成 原因:暂无示例 |
缺陷报告
下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。
缺陷报告 | 应用于 | 出版时的行为 | 正确行为 |
---|---|---|---|
LWG 2193 | C++11 | 默认构造函数为 explicit | 使之为非 explicit |
参阅
赋值给容器 (公开成员函数) |