Why does placing a function inside parenthesis disable ADL for that function?

Hi,

I found in good literature that:

1
2
3
4
5
6
template<typename T>
void Sample4( T t)
{
  S4Helpers::bar(t);          // disables ADT (Argument Dependent Lookup)
  (bar)(t);                   // disables ADT
}


Why? Is it because bar is seen as a pointer to a function and not as a function itself?

Thanks,
Juan Dent
Last edited on
Is S4Helpers::bar(t) another template function?
In that case, it would not care what type of parameter it got.
The fifth line simply casts t to type bar. It does not call a function.
I'm not exactly sure what your question is?
ADL comes into the picture only when the postfix-expression in a function cal is an unqualified-id

S4Helpers::bar is an id-expression, but it is not an unqualified-id (it is a qualified-id).

(bar) is a primary-expression, but it is not an id-expression (because it is parenthesised).
Thanks JLBorges once again!!

theturk1234: I guess if bar were a type then it would be a cast - but if it wasn't then that would be a function call, I think. If a type bar existed and a function bar existed also, then it would probably be ambiguous.

Right?

Thanks again both of you!!

Juan
Topic archived. No new replies allowed.