This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


"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


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