名前空間
変種
操作

std::back_insert_iterator

提供: cppreference.com
< cpp‎ | iterator
2015年11月30日 (月) 06:22時点におけるP12bot (トーク | 投稿記録)による版

 
 
イテレータライブラリ
イテレータコンセプト
イテレータプリミティブ
アルゴリズムのコンセプトとユーティリティ
間接呼び出し可能コンセプト
共通アルゴリズム要件
ユーティリティ
イテレータアダプタ
ストリームイテレータ
イテレータのカスタマイゼーションポイント
イテレータ操作
(C++11)
(C++11)
範囲アクセス
(C++11)(C++14)
(C++11)(C++14)
(C++17)(C++20)
(C++14)(C++14)
(C++14)(C++14)
(C++17)
(C++17)
 
 
ヘッダ <iterator> で定義
template< class Container >

class back_insert_iterator : public std::iterator< std::output_iterator_tag,

                                                   void,void,void,void >
std::back_insert_iteratorLegacyOutputIteratorイテレータは(間接参照するかどうかにかかわらず)に割り当てられたときにそれを構成しているため、容器に付加が、コンテナのpush_back()メンバ関数を使用するということです。 std::back_insert_iteratorをインクリメントすると、操作は行われません.
Original:
std::back_insert_iterator is an LegacyOutputIterator that appends to a container for which it was constructed, using the container's push_back() member function whenever the iterator (whether dereferenced or not) is assigned to. Incrementing the std::back_insert_iterator is a no-op.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

メンバータイプ

メンバー·タイプ
Original:
Member type
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Definition
container_type Container

メンバ関数

テンプレート:cpp/iterator/inserter/dsc operator++
新しい back_insert_iterator を構築します
(パブリックメンバ関数) [edit]
紐付けられたコンテナにオブジェクトを挿入します
(パブリックメンバ関数) [edit]
何もしません
(パブリックメンバ関数) [edit]

メンバーオブジェクト

メンバー名
Original:
Member name
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Definition
container (保護されています)
タイプContainer*のポインタ
Original:
a pointer of type Container*
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

メンバ型

メンバ型 定義
iterator_category std::output_iterator_tag
value_type void
difference_type void
pointer void
reference void

メンバ型 iterator_categoryvalue_typedifference_typepointer および referencestd::iterator<std::output_iterator_tag, void, void, void, void> から継承することによって取得することが要求されます。

(C++17未満)

#include <iostream>
#include <iterator>
#include <algorithm>
#include <cstdlib>
int main()
{
    std::vector<int> v;
    std::generate_n(std::back_insert_iterator<std::vector<int>>(v), // can be simplified
                    10, [](){return std::rand()%10;});        // with std::back_inserter
    for(int n : v)
        std::cout << n << ' ';
    std::cout << '\n';
}

出力:

3 6 7 5 3 5 6 2 9 1

参照

引数から推定した型の std::back_insert_iterator を作成します
(関数テンプレート) [edit]
コンテナの先頭に挿入するためのイテレータアダプタ
(クラステンプレート) [edit]
コンテナに挿入するためのイテレータアダプタ
(クラステンプレート) [edit]