I am trying to use ostream_iterator for writing a vector of pairs to a file.ostream_iterator requires a template argument to be applied at the time of declaration. The vector is defined as-
vector<pair<string,long>> test;
When I pass pair as a template to the ostream_iterator it shows an error -
Error 1 error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'const std::pair<_Ty1,_Ty2>' (or there is no acceptable conversion) C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\iterator 531 1 wordsegmentation
What could be the correct argument in this situation?
Edit- Code Snippet
vector<pair<string,long>> t;
......
//t is filled up with elements
ostream_iterator<pair<string,long>> output_iterator(out, "\n");
std::copy(t.begin(), t.end(), output_iterator);