name-lookup Questions

2

Solved

Consider the following C++ code example: namespace n { struct A {}; } struct B {}; void foo(int) {} template<typename T> void quux() { foo(T()); } void foo(n::A) {} void foo(B) {} in...
Hexateuch asked 9/11, 2012 at 22:6

2

Solved

Why does the C++ standard define two phase lookup for templates? Couldn't non dependent declarations and definitions' lookups be deferred to the instantiation stage as well?
Celio asked 24/9, 2012 at 8:44

3

Solved

It recently came to my attention that member functions completely shadow free functions with the same name when inside the class. And by completely I mean that every free function with the same nam...
Disservice asked 27/7, 2012 at 21:42

2

Solved

class messageA { }; class messageB { }; template<class T> class queue { public: virtual ~queue() {} void submit(T& x) {} }; class A : public queue<messageA>, public queue<me...

1

The following code containing friend declaration fails with indicated error (see http://ideone.com/Kq5dy): template<class T> void foo() {} template<typename T> class A { void foo(); ...
Ineluctable asked 15/12, 2011 at 3:48

6

Solved

I have some code that, for the purposes of this question, boils down to template<typename T> class TemplateClass : public T { public: void method() {} template<typename U> static v...
Porfirioporgy asked 11/11, 2011 at 21:59

1

Solved

I have the following set of classes (a minimal replication of my real situation): namespace Parent { class A {}; namespace Nested { class A {}; } template <typename T> class B { A...
Xanthine asked 22/11, 2011 at 12:39

4

Solved

What are some good explanations on what argument dependent lookup is? Many people also call it Koenig Lookup as well. Preferably I'd like to know: Why is it a good thing? Why is it a bad thing? ...
Leela asked 13/11, 2011 at 12:58

2

Solved

While I investigate source code of Qt I saw that trolltech guys explicitly use this keyword to access a field on destructor. inline ~QScopedPointer() { T *oldD = this->d; Cleanup::cleanup(old...
Damsel asked 26/10, 2011 at 20:7

2

Solved

$10.2/4- "[ Note: Looking up a name in an elaborated-type-specifier (3.4.4) or base-specifier (Clause 10), for instance, ignores all nontype declarations, while looking up a name in a nested...
Lucania asked 4/11, 2010 at 6:1

2

Solved

Is this guaranteed to work: struct A { struct Gold {}; }; struct B : public A { typedef Gold BaseGold; struct Gold {}; }; struct C : public B { typedef Gold BaseGold; struct Gold {}; }; st...
Conferee asked 12/8, 2011 at 12:30

2

Solved

What I read in the C++ standard about injected class names contradicts (as I see it) with the behavior of a sample program I will present shortly. Here's what I read: From 3.4 (paragraph 3) Th...
Dominance asked 11/8, 2011 at 11:28

1

Solved

A point from ISO draft n3290 section 3.4.2 paragraph 1: When the postfix-expression in a function call is an unqualified-id, other namespaces not considered during the usual unqualified lookup m...
Orator asked 2/6, 2011 at 6:27

2

Solved

I have the following code: #include "stdafx.h" #include <iostream> using namespace std; #include <conio.h> #include <cstring> #include <iomanip> void swap(long a, long b) ...
Reply asked 7/5, 2011 at 5:21

1

Solved

I have the following code example that doesn't compile: #include <stdio.h> namespace my { class base1 { // line 6 }; class base2: private base1 { }; class derived: private base2 {...
Thirza asked 12/4, 2011 at 11:44

1

Solved

I have code like this: namespace N { class B { public: virtual void doStuff(B *) = 0; }; } // not in a namespace class Derived : public N::B { public: void doStuff(B *); // Should this b...
Geodetic asked 25/11, 2010 at 13:20

2

#include <iostream> #include <cmath> #include <vector> using namespace std; int square(int a){ return a*a; } struct Point{ int x,y; }; int distance (const Point& a,...

4

Solved

Consider: #include <iostream> using namespace std; struct A { virtual void f() { cout << "A::f" << endl; } virtual void f() const { cout << "A::f const" << endl; ...
Slovenia asked 11/11, 2010 at 9:9

2

Solved

$7.3.3/14 (C++03) struct A { int x(); }; struct B : A { }; struct C : A { using A::x; int x(int); }; struct D : B, C { using C::x; int x(double); }; int f(D* d) { return d->x(); // ambiguo...
Archaic asked 9/11, 2010 at 3:14

3

Solved

Compiling this code using g++ 4.2.1: struct S { }; template<typename T> struct ST { }; template<typename BaseType> class ref_count : private BaseType { }; template<typename RefCou...

5

Solved

The following code doesn't compile with gcc, but does with Visual Studio: template <typename T> class A { public: T foo; }; template <typename T> class B: public A <T> { public:...
Githens asked 14/8, 2008 at 17:39

© 2022 - 2024 — McMap. All rights reserved.