c++/8279: REGRESSION: failure to find a matching function in ostream_iterator expansion

Wolfgang Bangerth bangerth@ticam.utexas.edu
Mon Oct 21 09:02:00 GMT 2002


The testcase fails for a relatively simple reason: copying to an 
ostream_iterator invokes ostream_iterator::operator=, which here looks 
like this:
      ostream_iterator& 
      operator=(const _Tp& __value) 
      { 
	*_M_stream << __value;
	//...
	return *this;
      }
_M_stream is of type std::ostream, and __value of type _Tp=std::pair. So 
the compiler looks for an operator
      std::ostream << std::pair

Since the declaration of this class is in namespace std, in looks for this 
operator in namespace std. Since both types are in namespace std, Koenig 
lookup also does not bring in additional namespaces. It will thus not find 
the globally declared operator of the test case.

This also explains, why it is not compilable with icc6, as well as that it 
compiled with gcc2.95, since that did not know about namespace std.

I don't think there is a simple solution to work around this, short of 
putting the respective operator in namespace std.

At least, I believe the compiler is right to reject the code, and that 
this is not a bug.

Regards
  Wolfgang

-------------------------------------------------------------------------
Wolfgang Bangerth              email:           bangerth@ticam.utexas.edu
                               www: http://www.ticam.utexas.edu/~bangerth




More information about the Gcc-bugs mailing list