Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c++ > #383

Unqualified name lookup

From koszal<krasnal1972@gmail.com>
Newsgroups comp.std.c++
Subject Unqualified name lookup
Followup-To comp.std.c++
Date 2011-12-03 08:24 -0800
Organization http://groups.google.com
Message-ID <f6695839-d821-47f5-a1f6-e87604daa072@w3g2000vbw.googlegroups.com> (permalink)

Followups directed to: comp.std.c++

Show all headers | View raw


Hello all,

I'm looking for some explanation of the unqualified name lookup
specified in the spec.
In particular there is an example in the point 3.4.1$3:

typedef int f;
namespace N {
     struct A {
         friend void f(A&);
         operator int();
         void g(A a) {
             int i = f(a); // f is the typedef, not the friend
                             // function: equivalent to int(a)
         }
     };
}

and the text below it says:
[1] "because the expression is not a function call, the argument-
dependent name lookup (3.4.2) does not apply and the friend function f
is not found".

Why the expression 'f(a)' is not a function call?  Could somebody
explain to me how compiler infers here that this is a functional style
cast and not a function call?

I just can't wrap my head around this - especially if I take into
account that the note above this example says:
[2] "For purposes of determining (during parsing) whether an
expression is a postfix-expression for a function call, the usual name
lookup rules apply. The rules in 3.4.2 have no effect on the syntactic
interpretation of an expression."

My reading of this results in the following expectations for this
particular example:
1. var 'i' is initialized by the expression 'f(a)'
2. there is an ambiguity since 'f(a)' could be a function style cast
or a function call
3. 'f' should be looked up for what it is and friend function is found
4. ambiguity is resolved and this should be treated as a function call
5. there is a typing error which should be reported by the user
Could anybody fix this list for me - most suspected is point 3 but the
text [1] says that is not a function call so maybe point 2 is also
wrong?

I'd appreciate any explanations

Best regards
Andrzej Ostruszka


-- 
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]

Back to comp.std.c++ | Previous | NextNext in thread | Find similar


Thread

Unqualified name lookup koszal<krasnal1972@gmail.com> - 2011-12-03 08:24 -0800
  Re: Unqualified name lookup Francis Glassborow <francis.glassborow@btinternet.com> - 2011-12-04 02:23 -0800
    Re: Unqualified name lookup gayan.harutyunyan@googlemail.com - 2012-09-26 17:09 -0700

csiph-web