using declaration and ADL

F

Fraser Ross

Is it true that ADL will be done even in the presence of a using declaration
as someone said recently at comp.lang.c++.moderated?

Fraser.
 
H

Howard

Fraser Ross said:
Is it true that ADL will be done even in the presence of a using
declaration
as someone said recently at comp.lang.c++.moderated?

That's not much info to go on. I had to go look up what ADL meant:
argument-dependent lookup. That still doesn't tell me the context of what
you're discussing, or why it matters.

(Please tell me you're not arguing about this with mister Hatton. If so,
give it up. You'll never resolve anything.)

-Howard
 
F

Fraser Ross

From the moderated group:


This is an error of your compiler (I know, it's a g++ :) ). And I
think, that Wolfgang's wrong, using declaration can not stop ADL
lookup. In this
example g++ can find both functions (and that's right) and it's an
ambiguity:

namespace N
{
struct A;
}

namespace Odd
{
void fun(N::A&)
{
}
}

namespace N
{
struct A{};

void fun(A&)
{
}
}

int main()
{
using Odd::fun;
N::A a;
fun(a);
}

End quote.

There is not a reference to a paragraph in the standard. I will be doubtful
until I see one.

Fraser.
 
V

Victor Bazarov

Fraser said:
From the moderated group:


This is an error of your compiler (I know, it's a g++ :) ). And I
think, that Wolfgang's wrong, using declaration can not stop ADL
lookup. In this
example g++ can find both functions (and that's right) and it's an
ambiguity:

namespace N
{
struct A;
}

namespace Odd
{
void fun(N::A&)
{
}
}

namespace N
{
struct A{};

void fun(A&)
{
}
}

int main()
{
using Odd::fun;
N::A a;
fun(a);
}

End quote.

There is not a reference to a paragraph in the standard. I will be doubtful
until I see one.

3.4.2/2a. "Otherwise the set of declarations found by the lookup of the
function name is the union..."

Regular unqualified lookup should find 'Odd::fun' and argument-dependent
lookup adds 'N::fun' to the set, causing ambiguity.

V
 
F

Fraser Ross

"Victor Bazarov"
3.4.2/2a. "Otherwise the set of declarations found by the lookup of the
function name is the union..."

Regular unqualified lookup should find 'Odd::fun' and argument-dependent
lookup adds 'N::fun' to the set, causing ambiguity.

Thats not referring to using declarations. The section I wanted to see must
be 7.3.3/12.

Fraser.
 
V

Victor Bazarov

Fraser said:
"Victor Bazarov"



Thats not referring to using declarations. The section I wanted to see must
be 7.3.3/12.

I thought that went without saying. The difference is really in ADL
itself, IMO. The main thing is that if a _member_ function is found,
other scopes are not considered for ADL. Now, with regular names (non-
members) all scopes are considered and all names are bundled for overload
resolution purposes.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top