-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathTwoPhaseNameLookup.cpp
More file actions
71 lines (59 loc) · 1.65 KB
/
TwoPhaseNameLookup.cpp
File metadata and controls
71 lines (59 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// =====================================================================================
// TwoPhaseNameLookup.cpp
// =====================================================================================
module modern_cpp:two_phase_name_lookup;
namespace TwoPhaseNameLookup
{
// Non-Template Code Example:
class Base {
public:
void doSomething() {
std::cout << "doSomething" << std::endl;
}
};
class Derived : public Base {
public:
void callBase() {
doSomething();
}
};
// Template Code Example:
template <typename T>
class BaseEx {
public:
void doSomething() {
std::cout << "doSomething" << std::endl;
}
};
template <typename T>
class DerivedEx : public BaseEx<T> {
public:
// using BaseEx<T>::doSomething;
void callBase() {
// doSomething(); // <=== remove comment:
this->doSomething();
BaseEx<T>::doSomething();
}
};
/*
* Note Error Message:
* 'doSomething': function declaration must be available as none of the arguments depend on a template parameter
*/
static void test_01() {
Derived derived;
derived.callBase();
}
static void test_02() {
DerivedEx<int> derived;
derived.callBase();
}
}
void main_two_phase_name_lookup()
{
using namespace TwoPhaseNameLookup;
test_01();
test_02();
}
// =====================================================================================
// End-of-File
// =====================================================================================