1

ここに、STL の pdf からの基本的な例があります。うまくいかないのはなぜですか?

#include "stdafx.h"
#include <vector>
#include <algorithm>
#include <iostream>
#include <iterator>

using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
    vector<string> coll;
    copy(istream_iterator<string>(cin), //start of source
            istream_iterator<string>(), //end of source
            back_inserter(coll));
    return 0;
}

エラー:

ClCompile:   All outputs are up-to-date.
stl_testing1.cpp
c:\program files\microsoft visual studio 10.0\vc\include\iterator(470): error C2678: binary '>>' :
no operator found which takes a left-hand operand of type 'std::basic_istream<_Elem,_Traits>' (or there is no acceptable conversion)
          with
          [
              _Elem=char,
              _Traits=std::char_traits<char>
          ]
          c:\program files\microsoft visual studio 10.0\vc\include\istream(1053): could be 'std::basic_istream<_Elem,_Traits> &std::operator
>><std::char_traits<char>>(std::basic_istream<_Elem,_Traits> &&,signed char *)'
          with
          [
              _Elem=char,
              _Traits=std::char_traits<char>
          ]
          c:\program files\microsoft visual studio 10.0\vc\include\istream(1060): or       'std::basic_istream<_Elem,_Traits> &std::operator
>><std::char_traits<char>>(std::basic_istream<_Elem,_Traits> &&,signed char &)'
          with
          [
              _Elem=char,
              _Traits=std::char_traits<char>
          ]
          c:\program files\microsoft visual studio 10.0\vc\include\istream(1067): or       'std::basic_istream<_Elem,_Traits> &std::operator
>><std::char_traits<char>>(std::basic_istream<_Elem,_Traits> &&,unsigned char *)'
          with

何が悪いのだろうか。これは Win32 コンソール アプリケーションです。

4

1 に答える 1

4
#include <string>

これは役立つかもしれません。

于 2012-02-09T19:39:36.333 に答える