=====
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>
using std::ostream_iterator;
using std::copy;
using std::cout;
using std::endl;
using std::vector;
using std::ostream;
namespace example {
struct A
{
};
}
ostream& operator<<(ostream& os, const example::A& a)
{
os << "Foo! ";
return os;
}
int main()
{
vector<example::Afoo(1);
cout << foo.at(0) << endl;
// ostream_iterator<example::Abar(cout, "\n");
// copy(foo.begin(), foo.end(), bar);
return 0;
}
=====
I can use the operator<< for the first statement to cout without any
problems. When attempting to use an ostream_iterator and copy() to
achieve the same effect, I get tons of incomprehensible STL errors.
Using gfilt on it--yes, I know gfilt doesn't officially support G++ 4
yet, but I've had good experiences using it to simplify things
nevertheless--I get:
BD Software STL Message Decryptor v2.47a for gcc
stream_iterator.h: In member function 'ostream_iterator<
example::A, char, char_traits<char>
& ostream_iterator<example::A, char, char_traits<char>const example::A &
::operator=(
)':
[STL Decryptor: Suppressed 4 more STL standard header messages]
test.cc:30: instantiated from here
stream_iterator.h:196: error: no match for 'operator<<' in '*(
(ostream_iterator<example::A, char, char_traits<char *)this
)->ostream_iterator<example::A, char, char_traits<char>
>::_M_stream <<__value'
.... which is still not especially helpful to me.
Can someone help me out with figuring out precisely what invocation I
need to introduce in order to get ostream_iterator to support the
output of namespaced types?