Problem with ostream_iterator
Chan Shih-Ping
cshihpin@dso.org.sg
Sat Apr 1 00:00:00 GMT 2000
System: gcc-2.95.2/libstdc++-2.90.7 with --enable-namespaces
The following ostream_iterator code does not
compile with -fhonor-std
//Code taken from testsuite multiset.cc
//Define operator<< for pairs
std::ostream&
operator<<(std::ostream& os, const std::pair<int, int>& p)
{
return os << p.first << ' ' << p.second;
}
main()
{
std::pair<int, int> p(12,34);
//this compiles and works
std::cout << p << std::endl;
std::ostream_iterator<pair<int, int> > out(std::cout, "\n");
//This fails to compile: why?
//The complaint by the compiler is
//not being able to find the function
//std::ostream& operator<<(std::ostream&, const pair<int, int>&)
//which is defined above
*out = p;
}
More information about the Libstdc++
mailing list