R
Robert J. Hansen
In the following code:
=====
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>
using std:stream_iterator;
using std::copy;
using std::cout;
using std::endl;
using std::vector;
using std:stream;
namespace example {
struct A
{
};
}
ostream& operator<<(ostream& os, const example::A& a)
{
os << "Foo! ";
return os;
}
int main()
{
vector<example::A> foo(1);
cout << foo.at(0) << endl;
// ostream_iterator<example::A> bar(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<
)':
[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 '*(
.... 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?
=====
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>
using std:stream_iterator;
using std::copy;
using std::cout;
using std::endl;
using std::vector;
using std:stream;
namespace example {
struct A
{
};
}
ostream& operator<<(ostream& os, const example::A& a)
{
os << "Foo! ";
return os;
}
int main()
{
vector<example::A> foo(1);
cout << foo.at(0) << endl;
// ostream_iterator<example::A> bar(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<
const example::A &example::A said:> & ostream_iterator<example::A, char, char_traits<char>
:perator=(
)':
[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 '*(
__value'(ostream_iterator said:::_M_stream <<
.... 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?