This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: typedef of pair<> != pair<> in copy(); have to define pair<> derived class
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: <mhcox at bluezoosoftware dot com>
- Cc: "GCC Help" <gcc-help at gcc dot gnu dot org>, "GCC Bugs" <gcc-bugs at gcc dot gnu dot org>
- Date: 18 Feb 2003 08:58:36 +0100
- Subject: Re: typedef of pair<> != pair<> in copy(); have to define pair<> derived class
- Organization: Integrable Solutions
- References: <NDBBJEBGAAGAIKPGOOFICEIKEHAA.mhcox@bluezoosoftware.com>
"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