Usenet.com

www.Usenet.com

Group Index

Comp Thread Archive from Usenet.com

<-- __Chronological__ --> <-- __Thread__ -->

Re: Koenig lookup problem???



Dave wrote:
> #include <iostream>
> 
> using std::cout;
> using std::endl;
> 
> // #define CAUSE_ERROR
> 
> namespace N
> {
>    struct foo_t {};
>    void foo_func(foo_t) {cout << "Got here!" << endl;}
> }
> 
> int main()
> {
> #ifdef CAUSE_ERROR
>    // EXPECTED ERROR - the parentheses surrounding the function name inhibit
>    // argument-dependent (Koenig) lookup, so the identifier foo_func will
> not
>    // be found.
>    (foo_func)(N::foo_t());
> #else
>    foo_func(N::foo_t()); // This call should and does compile fine.
> 
>    // Here, the same call that generates an error above works fine.  I would
>    // have expected an error here due to the suppression of Koenig lookup (as
>    // above).  Is this behavior Standard-compliant, or have I indeed found a bug
>    // in my implementation (VC++ 7.1)???
>    (foo_func)(N::foo_t());
> #endif
> }

It's a bug.  There's no reason why the successful argument-dependent
lookup should affect lookup in the second statement.

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]



<-- __Chronological__ --> <-- __Thread__ -->


Usenet.com



Please check out one of the premium Usenet Newsgroup Service Providers below for access to Usenet.