`std::set` 的推导指引
定义于头文件 <set> |
||
template< class InputIt, |
(1) | (since C++17) |
template< class Key, class Comp = std::less<Key>, |
(2) | (since C++17) |
template< class InputIt, class Alloc > set( InputIt, InputIt, Alloc ) |
(3) | (since C++17) |
template< class Key, class Alloc > set( std::initializer_list<Key>, Alloc ) |
(4) | (since 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) | (since C++23) |
template< ranges::input_range R, class Alloc > set( std::from_range_t, R&&, Alloc ) |
(6) | (since C++23) |
这些重载仅在 InputIt
满足 LegacyInputIterator,Alloc
满足 Allocator,且 Comp
不满足 Allocator 时参与重载解析。
注意:库确定类型不满足 LegacyInputIterator 的程度是未指定的,但至少 integral 类型不符合输入迭代器的条件。同样,它确定类型不满足 Allocator 的程度是未指定的,但至少成员类型 Alloc::value_type
必须存在,并且表达式 std::declval<Alloc&>().allocate(std::size_t{}) 当作为未求值操作数处理时,必须是良构的。
[编辑] 注释
特性测试宏 | 值 | Std | 特性 |
---|---|---|---|
__cpp_lib_containers_ranges |
202202L |
(C++23) | 范围感知构造和插入;重载 (5,6) |