g++ doesn't seem to find the matching operator<< when std::copy()ing a std::map to an output_iterator Error is like this: /usr/include/c++/3.2/bits/stream_iterator.h: In member function td::ostream_iterator<_Tp, _CharT, _Traits>& std::ostream_iterator<_Tp, _CharT, _Traits>::operator=(const _Tp&) [with _Tp = std::pair<std::string, int>, _CharT = char, _Traits = std::char_traits<char>]': mapproblem.cc:228: instantiated from OutputIter std::__copy(_InputIter, _InputIter, _OutputIter, std::input_iterator_tag) [with _InputIter = std::_Rb_tree_iterator<std::pair<const std::string, int>, std::pair<const std::string, int>&, std::pair<const std::string, int>*>, _OutputIter = std::ostream_iterator<std::pair<std::string, int>, char, std::char_traits<char> >]' mapproblem.cc:260: instantiated from OutputIter std::__copy_aux2(_InputIter, _InputIter, _OutputIter, __false_type) [with _InputIter = std::_Rb_tree_iterator<std::pair<const std::string, int>, std::pair<const std::string, int>&, std::pair<const std::string, int>*>, _OutputIter = std::ostream_iterator<std::pair<std::string, int>, char, std::char_traits<char> >]' mapproblem.cc:298: instantiated from OutputIter std::__copy_ni2(_InputIter, _InputIter, _OutputIter, __false_type) [with _InputIter = std::_Rb_tree_iterator<std::pair<const std::string, int>, std::pair<const std::string, int>&, std::pair<const std::string, int>*>, _OutputIter = std::ostream_iterator<std::pair<std::string, int>, char, std::char_traits<char> >]' mapproblem.cc:321: instantiated from OutputIter std::__copy_ni1(_InputIter, _InputIter, _OutputIter, __false_type) [with _InputIter = std::_Rb_tree_iterator<std::pair<const std::string, int>, std::pair<const std::string, int>&, std::pair<const std::string, int>*>, _OutputIter = std::ostream_iterator<std::pair<std::string, int>, char, std::char_traits<char> >]' mapproblem.cc:342: instantiated from OutputIter std::copy(_InputIter, _InputIter, _OutputIter) [with _InputIter = std::_Rb_tree_iterator<std::pair<const std::string, int>, std::pair<const std::string, int>&, std::pair<const std::string, int>*>, _OutputIter = std::ostream_iterator<std::pair<std::string, int>, char, std::char_traits<char> >]' mapproblem.cc:21: instantiated from here /usr/include/c++/3.2/bits/stream_iterator.h:141: no match for std::basic_ostream<char, std::char_traits<char> >& << const std::pair<std::string, int>&' operator /usr/include/c++/3.2/bits/ostream.tcc:55: candidates are: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>&(*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>] (...) Release: 3.2 Environment: System: Linux aris.dummy.de 2.4.19-pre8 #1 Sam Mai 4 18:10:42 CEST 2002 i686 unknown Architecture: i686 host: i686-pc-linux-gnu build: i686-pc-linux-gnu target: i686-pc-linux-gnu configured with: ../configure --prefix=/usr --enable-languages=c,c++ How-To-Repeat: Try to compile this: #include <cstdlib> #include <iostream> #include <string> #include <map> #include <algorithm> #include <iterator> std::ostream& operator<< (std::ostream& ostr, const std::pair<std::string,int>& mypair) { return ostr << mypair.first; } int main (void) { std::map<std::string,int> mymap; mymap[std::string("myid1")] = 1; mymap[std::string("myid2")] = 2; std::copy (mymap.begin (), mymap.end (), std::ostream_iterator<std::pair<std::string,int> > (std::cout, " ")); return EXIT_SUCCESS; }
Fix: Really don't know. However, I had no problem compiling this with Intel's C++ 5.0 compiler on Linux
State-Changed-From-To: open->closed State-Changed-Why: Your op<< is in the global namespace, but at the place where it is used (inside std::copy and the ostream_iterator), only operators in namespace std are looked up because both operands are in namespace std. There are several other instances of this bug/feature in the database. You can work around the problem by putting the op<< into namespace std.
Lovely article - one of the best things I've recently read, and by far the most useful. I had a good experience filling forms online and happy to share it with you. I've found PDFfiller - online service for forms filling. It's pretty easy to use and pretty cheap. You can find fillable a form here http://goo.gl/Ms4ebj