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: Templated insertion operators


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


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