次の方法で共有


unordered_set::emplace_hint

構築された要素を適切な場所に追加します。

template<class ValTy>
    iterator emplace_hint(const_iterator where, ValTy&& val);

パラメーター

パラメーター

Description

ValTy

インプレース コンストラクターの引数の型。

val

挿入する値。

where

コンテナー内の挿入位置 (ヒントのみ)。

解説

このメンバー関数は、被制御シーケンス内の挿入位置の検索開始位置として where を使用して、insert(move(val)).first を返します。挿入位置が where の直前または直後である場合、挿入処理が若干速くなる可能性があります。

挿入時に例外がスローされた場合、コンテナーは変更されず、再度例外がスローされます。

例 

Dd779103.collapse_all(ja-jp,VS.110).gifコード

// std_tr1__unordered_set__unordered_set_emplace_hint.cpp 
// compile with: /EHsc 
#include <unordered_set> 
#include <iostream>
#include <string> 
 
    unordered_set< string> c1;
    string str1("a");

    c1.emplace_hint(c1.begin(), move(str1));
    cout << "After the emplace insertion, c1 contains: "
        << *c1.begin() << endl;
 
     return (0); 
    } 
 

Dd779103.collapse_all(ja-jp,VS.110).gif出力

After the emplace insertion, c1 contains: a

必要条件

ヘッダー : <unordered_set>

名前空間: std

参照

関連項目

<unordered_set>

unordered_set クラス

その他の技術情報

<unordered_set> メンバー