Questions tagged [name-lookup]

Name lookup is the procedure by which a name, when encountered in a program, is associated with the declaration that introduced it.

For function names, name lookup can associate multiple declarations with the same name, and may obtain additional declarations from . Template argument deduction may also apply, and the set of declarations is passed to overload resolution, which selects the declaration that will be used. Member access rules, if applicable, are considered only after name lookup and overload resolution. For all other names (variables, namespaces, classes, etc), name lookup must produce a single declaration in order for the program to compile.

Unqualified name lookup

For an unqualified name, that is name that does not appear to the right of a scope resolution operator ::, name lookup examines the scopes as described below, until it finds at least one declaration of any kind, at which time the lookup stops and no further scopes are examined.

For the purpose of unqualified name lookup, all declarations from a namespace mentioned by a using directive are members of the namespace in which the using-directive appears.

303 questions
0
votes
0 answers

Updating a field by looking up same field in another table

I have 3 tables: Regtable finaltable ptable I want to update a QTRcontractend field in finaltable with QTRcontractend field in REGtable if ID from finaltable is present in regtable I have written the below code but get an error that my subquery has…
0
votes
1 answer

Resolving multiple inheritance ambiguity with enable_if

I have an event source base class, which defines a function to add listeners, and I'm trying to use a template argument to resolve ambiguity. But that doesn't seem to work - it always uses the function from the first base class and then complains…
riv
  • 6,846
  • 2
  • 34
  • 63
0
votes
0 answers

C++ out-of-namespace definition

On this site there is the following paragraph: Out-of-namespace definitions and redeclarations are only allowed after the point of declaration, only at namespace scope, and only in namespaces that enclose the original namespace (including the…
user42768
  • 1,951
  • 11
  • 22
0
votes
1 answer

Why does the name lookup does not stop when it finds the entity implicitly declared by using directive?

Here is the code example: #include using namespace std; namespace B { int ohoh=2; } namespace A { int ohoh=666; namespace C { //using B::ohoh;(as if declared by using directive) //why does the lookup not stops here? …
choxsword
  • 3,187
  • 18
  • 44
0
votes
1 answer

SSIS variable lookup of existing subfolders by name

I have added a File System Task to an SSIS package for the purpose of creating 7 new subfolders in 24 existing directory subfolders based on a purchase order number. The first var titled MainFolderPath is to the main system where the existing and…
David F
  • 265
  • 2
  • 14
0
votes
2 answers

Is there an implicit pointer to base class subobject when accessing one of its members?

If we had this code: class Base { int anint; float afloat; }; class Derived : Base { //inherited member variables... }; I have been told that members of Base would be inherited to Derived and these the inherited members in Derived are actually…
user8626782
0
votes
1 answer

name lookup troubles with fundamental and user defined types

This compiles: struct type{}; template void foo(T in) { bar(in, type()); } void bar(int, const type&) {} int main() { foo(42); } And this does not (as I learned in my previous question from today): template void foo(T in)…
0
votes
0 answers

Calling a template member function having existing name

please see the following code: namespace std { template auto& get(my_tuple_like_type& t) { std::size_t ext = t.template extent(); // This line // .... do something with ext and return …
Junekey Jeon
  • 1,496
  • 1
  • 11
  • 18
0
votes
2 answers

How to hide `A::x` and expose `B::x` only in such a case?

namespace A { int a = 1; int x = 2; } namespace B { int b = 3; int x = 4; } using namespace A; using namespace B; using B::x; int main() { return x; // error : reference to 'x' is ambiguous } How to hide A::x and expose B::x only in such…
xmllmx
  • 39,765
  • 26
  • 162
  • 323
0
votes
0 answers

Why do member names hide type-dependent name lookup?

If I have a free function: enum BOM { utf8, utf16le }; size_t length(BOM b); And then I have a class with a member named length: struct foo { BOM m_bom; size_t length() { return length(m_bom); } }; Why does the use of length(m_bom)…
Mordachai
  • 9,412
  • 6
  • 60
  • 112
0
votes
2 answers

effects of using declaration on name lookup for two exactly same names

Basically, my question is related to name lookup and using declaration (http://en.cppreference.com/w/cpp/language/namespace). Suppose we have the following (definitely stupid) codes: class Base { public: void fun() {std::cout << "Base…
Changgong Zhang
  • 167
  • 1
  • 5
0
votes
1 answer

Why is this piece of code "not ambigious!" - virtual functions

Why is the below code not ambiguous and how it works fine? #include #include using namespace std; class Shape{ public: virtual void drawShape(){ cout << "this is base class and virtual function\n"; …
0
votes
1 answer

How compiler works in case of error: reference to ‘mytype’ is ambiguous

I have created one scenario where I want help. Below code is the sample test application for same. #include using namespace std; class A { public: typedef int mytype; mytype GetInt() { return 1;} }; class B { public: …
Swapnil
  • 1,424
  • 2
  • 19
  • 30
0
votes
1 answer

Forcing name lookup to consider namespace scope

This question is somewhat related to point of instantiation and name binding but not exactly. The question is about the standard and how it resolve lookup of symbols inside template definitions. Consider this example, loosely based on ostream…
Mats Kindahl
  • 1,863
  • 14
  • 25
0
votes
1 answer

Need guidance on two-dimensional lookup

I have a workbook with two worksheets. On the first worksheet titled "Report", I want to get data from my second worksheet, titled "DataSets". Ideally, I would like to have three or four tables on DataSets, and in Report I would like to be able to…
Blankdud
  • 698
  • 5
  • 9
  • 22