This is the mail archive of the gcc-help@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: ADL Help



Thanks Elijay,


| | It seems like the "here 1" version would be found but it is not. Can
| | you help me to understand what I'm missing?
|
| If you change main to...
|
| int main() {
| parm.f(parm);
| return 0;
| }
|
| ...or (recommended)...
|
| int main() {
| NS::T::f(parm);
| return 0;
| }
|
| ...then "here 1" will be used.
|
| I was surprised to see that ungarnished f(parm) used NS::f without having to
| specify NS:: or using namespace NS or using NS::f ... that smells like a bug
| in the compiler.


I may be frustrating the people trying to help me.  I am mainly trying
to understand how ADL works.  I seems like if I understood it fully, I
could take advantage of it for some of the templates I am trying to
write.  I did not mention all that because I just assumed it would
muddy the waters.  In the background, I am thinking that ADL could
help me since it could resolve references at the point the template is
used.  But, so far, I have not been able to understand the simple
cases.

The typical example for ADL uses namespaces and a simple program
almost exactly what I posted except the "struct" has been replaced
with "namespace".  The "beauty" of ADL is that f is found because the
namespaces that the type of parm is defined is searched.  I can get
the trivial examples to work for namespaces but the specification
includes not just namespaces but also classes.  But I can't get it to
work for class types.

I don't think this is a bug because I can test with IBM's xlC and it
does exactly the same thing in all cases that I've tried.  So, I'm
just missing something but I can't figure out what I'm missing.

It may be a small clause "when ADL is applied".  It might be that ADL
is not being applied in this case for some reason -- but I am not
understanding why it is applied when "namespace" is in the program but
not when "struct" (or "class") is used.

I appreciate any tips and clues anyone can supply.  I've puzzled over
this for most of a day and can't see what I'm missing.

Thank you again,
Perry Smith
Ease Software, Inc.
pedz@easesoftware.com
http://www.easesoftware.com

SATA Products for IBMs RS/6000, pSeries, and AIX systems


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