deduction guides for
std::map
|
定义于头文件
<map>
|
||
|
template
<
class
InputIt,
class
Comp
=
std::
less
<
/*iter-key-t*/
<
InputIt
>>
,
|
(1) | (C++17 起) |
|
template
<
class
Key,
class
T,
|
(2) | (C++17 起) |
|
template
<
class
InputIt,
class
Alloc
>
map
(
InputIt, InputIt, Alloc
)
|
(3) | (C++17 起) |
|
template
<
class
Key,
class
T,
class
Alloc
>
map
(
std::
initializer_list
<
std::
pair
<
Key, T
>>
, Alloc
)
|
(4) | (C++17 起) |
|
template
<
ranges::
input_range
R,
class
Compare
=
std::
less
<
/*range-key-t*/
<
R
>
,
class
Alloc
=
std::
allocator
<
/*range-to-alloc-t*/
<
R
>>
>
|
(5) | (C++23 起) |
|
template
<
ranges::
input_range
R,
class
Alloc
>
map
(
std::
from_range_t
, R
&&
, Alloc
)
|
(6) | (C++23 起) |
|
仅用于说明的辅助类型别名
|
||
|
template
<
class
InputIt
>
using
/*iter-val-t*/
=
|
( 仅用于说明* ) | |
|
template
<
class
InputIt
>
using
/*iter-key-t*/
=
|
( 仅用于说明* ) | |
|
template
<
class
InputIt
>
using
/*iter-mapped-t*/
=
|
<td class="t-d
这些重载仅当满足以下条件时参与重载决议:
InputIt
满足
LegacyInputIterator
要求,
Alloc
满足
Allocator
要求,且
Comp
不满足
Allocator
要求。
注意:库判定某个类型不满足
LegacyInputIterator
要求的程度是未指定的,但至少整型类型不符合输入迭代器的要求。同样地,库判定某个类型不满足
Allocator
要求的程度也是未指定的,但至少要求成员类型
Alloc::value_type
必须存在,且表达式
std::
declval
<
Alloc
&
>
(
)
.
allocate
(
std::
size_t
{
}
)
在被视为未求值操作数时必须保持良构。
说明
| 功能测试 宏 | 值 | 标准 | 功能特性 |
|---|---|---|---|
__cpp_lib_containers_ranges
|
202202L
|
(C++23) | 支持范围 的构造与插入;重载版本 ( 5,6 ) |
示例
缺陷报告
以下行为变更缺陷报告被追溯应用于先前发布的C++标准。
| DR | 适用范围 | 发布时的行为 | 正确行为 |
|---|---|---|---|
| LWG 3025 | C++17 | 初始化列表推导指南 ( 2,4 ) 采用 std:: pair < const Key, T > | 使用 std:: pair < Key, T > |