Questions tagged [token-name-resolution]

21 questions
43
votes
1 answer

List of C++ name resolution (and overloading) rules

Where I can find a list of the rules that a C++ compliant compiler must apply in order to perform names resolution (including overloading)? I'd like something like a natural-language algorithm or flow chart. C++ standard of course has this set of…
user781847
22
votes
1 answer

Declaration of method changes meaning of symbol

For the following code: struct foo {}; struct A { typedef foo foo_type; void foo(); }; GCC gives a compiler error: test.cpp:7:14: error: declaration of 'void A::foo()' [-fpermissive] void foo(); ^ test.cpp:1:8: error:…
HighCommander4
  • 50,428
  • 24
  • 122
  • 194
14
votes
3 answers

The actual result of name resolution in the class template is different from the c++ 03 standard

I test the code in the c++ standard ISO/IEC 14882-03 14.6.1/9 on Xcode 4.1 and Visual Studio 2008. The outputs of the two compiler are both different from the expected result of the standard. The code is pasted below. #include #include…
Jeffrey
  • 4,436
  • 9
  • 38
  • 54
10
votes
3 answers

Wrong name resolution when parent and inner class have the same name

I have an odd case with Visual Studio 2003. For somewhat legitimate reasons, I have the following hierarchy: class A {}; class B : public A { public: class A {}; }; class C : public B::A {}; That is, I have an inner class with the same name…
Michael Mrozek
  • 169,610
  • 28
  • 168
  • 175
8
votes
1 answer

Point of instantiation of a template class

Could that code to be compile? #include template struct TMPL { using TP = typename T::TP; //is CL::TP visible (with T == CL)? }; struct CL { using TP = int; TMPL::TP val; }; int main() { CL cl; } TMPL…
Denis
  • 2,786
  • 1
  • 14
  • 29
7
votes
1 answer

Differences of the interpretation of a non-dependent construct between definition context and point of instantiation in c++

N4527 14.6 [temp.res]/p8 If a hypothetical instantiation of a template immediately following its definition would be ill-formed due to a construct that does not depend on a template parameter, the program is ill-formed; no diagnostic is…
stackcpp
  • 1,275
  • 7
  • 15
6
votes
1 answer

Dependent name resolution & namespace std / Standard Library

While answering this SO question (better read this "duplicate"), I came up with the following solution to dependent name resolution of an operator: [temp.dep.res]/1: In resolving dependent names, names from the following sources are…
dyp
  • 38,334
  • 13
  • 112
  • 177
5
votes
3 answers

Reserved names in the global namespace

Arising from my answer to Dynamic array of objects in C++ and as a follow up to What are the rules about using an underscore in a C++ identifier?: apparently, names beginning with _ followed by an uppercase letter are reserved in the global…
rerun
  • 25,014
  • 6
  • 48
  • 78
4
votes
3 answers

why getenv() can get name resolved without a std::?

getenv() has a C++ implementation which can be included in the header file . So it is a member of namespace std. However, the getenv() function can be get resolved correctly in my code even without a std::getenv(), which means my follow program can…
Banchon
  • 43
  • 1
  • 5
4
votes
2 answers

How does a java compiler resolve a non-imported name

Consider I use a type X in my java compilation unit from package foo.bar and X is not defined in the compilation unit itself nor is it directly imported. How does a java compiler resolve X now efficiently? There are a few possibilities where X could…
gexicide
  • 38,535
  • 21
  • 92
  • 152
4
votes
1 answer

c++ namespace resolution ("automatic using" based on arguments?)

When I call a function declared in a namespace from outside this namespace, I usually need to explicitly prefix with the namespace: namespace ns1 { void myfunc(); } myfunc(); // compiler complains ns1::myfunc(); // good However I have…
Julien-L
  • 5,267
  • 3
  • 34
  • 51
3
votes
1 answer

Are there different rules regarding ADL or naming clashes with regard to overloaded operators?

I think this example best illustrates my question: namespace N { class C { public: friend bool operator==(const C& c, const C& x) { return true; } friend bool f(const C& c, const C& x) { …
odinthenerd
  • 5,422
  • 1
  • 32
  • 61
2
votes
2 answers

Resolving name clashes with builtins in a see also documentation section

I have the following class, with a method that hides (or shadows) a builtin function. I want the documentation to contain a "See Also" section, that links to the builtin function that is hidden. classdef CatHelper %CATHELPER Makes implementing…
Eric
  • 95,302
  • 53
  • 242
  • 374
1
vote
3 answers

How to refer to a type defined in a derived class passed as a template argument?

Consider the following example: template class A { private: typedef typename T::C C; }; template class B : public A> { public: typedef T C; }; int main() { B b; } Compiling it with GCC gives the…
vitaut
  • 49,672
  • 25
  • 199
  • 336
1
vote
2 answers

Does C++ use static name resolution or dynamic name resolution?

I have been reading about "Name resolution" in wikipedia (Name resolution WIKI) and it has been given in that that C++ uses "Static Name Resolution". If that is true then I couldn't figure out how C++ manages to provide "polymorphism" without using…
pasha
  • 2,035
  • 20
  • 34
1
2