This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Templated insertion operators
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Dan Gregory <dan dot gregory at mci dot com>
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: 30 Jan 2004 21:33:29 +0100
- Subject: Re: Templated insertion operators
- Organization: Integrable Solutions
- References: <401AB9AC.5090602@mci.com>
Dan Gregory <dan.gregory@mci.com> writes:
| When I move the operator<< into the namespace this problem goes away
| (so there's a workaround),
Well, I would not call it a workaround.
When you use the insertion operator (or any other operator for that
matter), the compiler looks into the current namespace and the
namespaces and classes associated with the arguments (hence the
terminology "argument-dependent name lookup") in search for matching
operator functions. That means that you're most advised to put your
operations declarations (and therefore their definitions) in the
namespace that contains your types. That is called the Interface
Principle.
-- Gaby