typedef of pair<> != pair<> in copy(); have to define pair<> derived class

Gabriel Dos Reis gdr@integrable-solutions.net
Tue Feb 18 07:59:00 GMT 2003


"Michael H. Cox" <mhcox@bluezoosoftware.com> writes:

| It seems like the following should compile (with USE_TYPEDEF=1), since a
| typedef of a std::pair<> class should be equivalent to the std::pair<>
| class.  To get it to compile, I had to declare a std::pair<> derived struct.
| Is this a compiler bug or pilot error on my part?

This is -not- a compiler bug.  

The compiler is behaving as mandated by the C++ standard.  The
insertion operator "<<" -- used by std::copy() --  is looked up
according to Argument Dependent Lookup (a.k.a. Koenig lookup). 
If Pathname is typedefed (in the global scope) then ADL will ignore
the global scope because it is not an associated namespace of Pathname
-- Pathname is synonymous to std::pair<> whose associated namespace is
std:: augmented with the associated namespaces of the template arguments.

-- Gaby



More information about the Gcc-bugs mailing list