istream_iterator::traits_type

提供 istream_iterator的性格字符类型的类型。

typedef Traits traits_type;

备注

类型作为模板参数的 特征的同义词。

示例

// 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;
}
  a10

FakePre-1e7fe26940c846ef84cace38e615f55b-de859c3b25834db3b56893b156a5cc7e

要求

头文件: <iterator>

命名空间: std

请参见

参考

istream_iterator 类

标准模板库