次の方法で共有


istream_iterator::traits_type

istream_iteratorの文字セットの型を提供する型。

typedef Traits traits_type;

解説

この型は、テンプレート パラメーター Traitsのシノニムです。

使用例

// istream_iterator_traits_type.cpp
// compile with: /EHsc
#include <iterator>
#include <iostream>

int main( )
{
   using namespace std;

   typedef istream_iterator<int>::char_type CHT1;
   typedef istream_iterator<int>::traits_type CHTR1;

   // Standard iterator interface for reading
   // elements from the input stream:
   cout << "Enter integers separated by spaces & then\n"
        << " any character ( try example: '10 20 a' ): ";

   // istream_iterator for reading int stream
   istream_iterator<int, CHT1, CHTR1> intRead ( cin );

   // End-of-stream iterator
   istream_iterator<int, CHT1, CHTR1> EOFintRead;

   while ( intRead != EOFintRead )
   {
      cout << "Reading:  " << *intRead << endl;
      ++intRead;
   }
   cout << endl;
}
  10 20 a
  10 20 a
& 空間と文字 (試行の例で区切られた整数を入力します: 「a) : 10 20  読み取り: 10 20  読み取ります: 10 20

必要条件

ヘッダー: <iterator>

名前空間: std

参照

関連項目

istream_iterator Class

標準テンプレート ライブラリ