This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: PR 4051
>>>>> "Phil" == Phil Edwards <pedwards@disaster.jaj.com> writes:
> 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.
They are. But as Alexandre says, the unqualified lookup starts in std,
finds a definition, and stops. It never hits global scope.
> 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.
It is a specialization of sorts...
Jason