std::multiset
的推導指南
在標頭檔案 <set> 中定義 |
||
template< class InputIt, |
(1) | (C++17 起) |
template< class Key, class Comp = std::less<Key>, |
(2) | (C++17 起) |
template< class InputIt, class Alloc > multiset( InputIt, InputIt, Alloc ) |
(3) | (C++17 起) |
template< class Key, class Alloc > multiset( 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 > multiset( 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) |
[編輯] 示例
#include <set> int main() { // guide #2 deduces std::multiset<int> std::multiset s = {1, 2, 3, 4}; // guide #1 deduces std::multiset<int> std::multiset s2(s.begin(), s.end()); }