std::multimap の推論ガイド
| ヘッダ <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 > multimap( InputIt, InputIt, Alloc ) |
(3) | (C++17以降) |
| template< class Key, class T, class Alloc > multimap( 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 > multimap( std::from_range_t, R&&, Alloc ) |
(6) | (C++23から) |
| Exposition-only helper type aliases |
||
| template< class InputIter > using iter_val_t = |
(説明用*) | |
| template< class InputIter > using iter_key_t = |
(説明用*) | |
| template< class InputIter > using iter_mapped_t = |
(説明用*) | |
| template< class InputIter > using iter_to_alloc_t = |
(説明用*) | |
| template< ranges::input_range Range > using range_key_t = |
(C++23から) (説明用*) |
|
| template< ranges::input_range Range > using range_mapped_t = |
(C++23から) (説明用*) |
|
| template< ranges::input_range Range > using range_to_alloc_t = |
(C++23から) (説明用*) |
|
multimap に対して提供されます。これらのオーバーロードは、InputIt が LegacyInputIterator を満たし、Alloc が Allocator を満たし、Comp が Allocator を満たさない場合にのみ、オーバーロード解決に参加します。
注意:ライブラリが型が LegacyInputIterator を満たさないと判断する範囲は未指定ですが、最小限として、整数型は入力イテレータとして適格ではありません。同様に、型が Allocator を満たさないと判断する範囲は未指定ですが、最小限として、メンバー型 Alloc::value_type が存在し、評価されないオペランドとして扱われた場合の式 std::declval<Alloc&>().allocate(std::size_t{}) が well-formed である必要があります。
[編集] 注記
| 機能テストマクロ | 値 | 規格 | 機能 |
|---|---|---|---|
__cpp_lib_containers_ranges |
202202L |
(C++23) | Ranges対応の構築と挿入。オーバーロード (5,6) |
[編集] 例
#include <map> int main() { // std::multimap m1 = {{"foo", 1}, {"bar", 2}}; // Error: braced-init-list has no type; cannot deduce // pair<Key, T> from {"foo", 1} or {"bar", 2} std::multimap m1 = {std::pair{"foo", 2}, {"bar", 3}}; // guide #2 std::multimap m2(m1.begin(), m1.end()); // guide #1 }
[編集] 不具合報告
以下の動作変更を伴う欠陥報告が、以前に公開されたC++標準に遡って適用されました。
| DR | 適用対象 | 公開された動作 | 正しい動作 |
|---|---|---|---|
| LWG 3025 | C++17 | initializer-listガイドは std::pair<const Key, T> を受け取ります | std::pair<Key, T> を使用してください |