Version information: [EMAIL PROTECTED] ~ $ g++ -v Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/specs Configured with: /var/tmp/portage/gcc-3.3.6/work/gcc-3.3.6/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.3.6 --includedir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3.6 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3.6/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3.6/info --with-gxx-include-dir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/include/g++-v3 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --disable-libunwind-exceptions --disable-multilib --disable-libgcj --enable-languages=c,c++,f77 --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu Thread model: posix gcc version 3.3.6 (Gentoo 3.3.6, ssp-3.3.6-1.0, pie-8.7.8)
I also found the same problem with a friends fedora core 4 with gcc 4. I have attached a cpp file that (I believe) should compile (and does on Borland c++). It is the copy at the end that causes a problem - the while loop is simply doing the same as what the copy should do (just to show I did the operator<< properly). Copy works for other cases (ints, floats, etc) and even for my own structs too. I'm just not sure why it complains about the operator<< function for a std::pair. Paul
#include <string> #include <vector> #include <iostream> #include <algorithm> #include <iterator> using namespace std; typedef pair<bool, float> MyPair; typedef vector<MyPair> MyPairColl; ostream& operator<<(ostream& os, const MyPair& myPair) { os << myPair.first << ' ' << myPair.second; return os; } int main() { const int maxElems = 100; MyPairColl coll(maxElems); for(int i=0; i<maxElems; ++i) { coll[i] = make_pair(i%2, 0.3 * i); } const MyPairColl::const_iterator itEnd(coll.end()); MyPairColl::const_iterator it(coll.begin()); while(it != itEnd) { cout << *it << ' '; ++it; } copy(coll.begin(), coll.end(), ostream_iterator<MyPair>(cout, " ")); }