What am I missing here?
#include <iostream>
using std::cout;
#include <vector>
using std::vector;
#include <string>
using std::string;
#include <algorithm>
using std::copy;
using std::remove;
#include <iterator>
using std::ostream_iterator;
#include <utility>
using std::pair;
vector<string>& descend(const char *path, const char *pattern, vector<string> &filelist);
void search(const char *path, const char *pattern, vector<string> &filelist);
std::ostream& operator<< (std::ostream &o, const pair<string, string> &p)
{
return o << p.first << ',' << p.second;
}
int main()
{
vector<string> wavs, phrases;
search("H:/projects/wavs/IT", "*.wav", wavs);
search("H:/projects/wavs/IT", "*.phr", phrases);
vector<pair<string, string> > renamer;
for ( vector<string>::iterator it = wavs.begin(); it != wavs.end(); ++it )
{
string temp(*it);
std::pair<string, string> entry;
entry.first = *it;
temp.erase(remove(temp.begin(),temp.end(),' '),temp.end());
temp.erase(remove(temp.begin(),temp.end(),'\''),temp.end());
temp.erase(remove(temp.begin(),temp.end(),'_'),temp.end());
temp.erase(remove(temp.begin(),temp.end(),'-'),temp.end());
entry.second = temp;
renamer.push_back(entry);
}
std::copy(wavs.begin(), wavs.end(), ostream_iterator<string>(cout, "\n"));
std::copy(phrases.begin(), phrases.end(), ostream_iterator<string>(cout, "\n"));
std::copy(renamer.begin(), renamer.end(), ostream_iterator<pair<string, string> >(cout, "\n"));
return 0;
}
It's a dirty, ugly hack, yes. But what am I doing wrong on the copy
to cout
?
*** {BD Software Proxy c++ v3.43a for gcc} STL Message Decryption is ON! ***
stream_iterator.h: In member function
`ostream_iterator<pair<string, string>, char, char_traits<char> > &
ostream_iterator<pair<string, string>, char, char_traits<char> >::operator=(
const pair<string, string> &
)':
[STL Decryptor: Suppressed 5 more STL standard header messages]
main.cpp:43: instantiated from here
stream_iterator.h:196: error: no match for 'operator<<' in '*(
(ostream_iterator<pair<string, string>, char, char_traits<char> > *)
this
)->ostream_iterator<pair<string, string>, char, char_traits<char> >
::_M_stream << __value'