std::set
的推导指南
在头文件 <set> 中定义 |
||
template< class InputIt, |
(1) | (C++17 起) |
template< class Key, class Comp = std::less<Key>, |
(2) | (C++17 起) |
template< class InputIt, class Alloc > set( InputIt, InputIt, Alloc ) |
(3) | (C++17 起) |
template< class Key, class Alloc > set( std::initializer_list<Key>, Alloc ) |
(4) | (C++17 起) |
template< ranges::input_range R, class Compare = less<ranges::range_value_t<R>>, class Alloc = std::allocator<ranges::range_value_t<R>> > |
(5) | (C++23 起) |
template< ranges::input_range R, class Alloc > set( std::from_range_t, R&&, Alloc ) |
(6) | (C++23 起) |
这些重载只有在 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) |