This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PR 4051


On Wed, Aug 22, 2001 at 07:49:16AM -0300, Alexandre Oliva wrote:
> Since ostream_iterator is defined in namespace std, the context in
> which the expression that outputs a pair to the ostream is that
> namespace, where a number of operator<<s that hide the definition in
> the global namespace exist.  Since the argumetns have type
> std::ostream and std::pair<int,int>, Koenig lookup only searches
> namespace std too.  So, the definition of ::operator<< isn't
> considered.  Does this make sense to anyone?

Wow, that's twisted.  :-)  I thought the usual unqualified name lookup rules
(which hit global scope pretty early) were executed before Koenig lookup.

But yeah, simply surrounding the op<< in the example code with 'namespace std
{' and '}' allows the code to compile cleanly, even though the function isn't
a template specialization (and thus has no business being in std).  Weird.


Phil

-- 
Would I had phrases that are not known, utterances that are strange, in
new language that has not been used, free from repetition, not an utterance
which has grown stale, which men of old have spoken.
                                     - anonymous Egyptian scribe, c.1700 BC


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]