From Jason Turner

[over.dcl]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp8w9zkuhy/{from.md → to.md} +0 -97
tmp/tmp8w9zkuhy/{from.md → to.md} RENAMED
@@ -1,97 +0,0 @@
1
- ## Declaration matching <a id="over.dcl">[[over.dcl]]</a>
2
-
3
- Two function declarations of the same name refer to the same function if
4
- they are in the same scope and have equivalent parameter declarations
5
- [[over.load]] and equivalent [[temp.over.link]] trailing
6
- *requires-clause*s, if any [[dcl.decl]].
7
-
8
- [*Note 1*:
9
-
10
- Since a *constraint-expression* is an unevaluated operand, equivalence
11
- compares the expressions without evaluating them.
12
-
13
- [*Example 1*:
14
-
15
- ``` cpp
16
- template<int I> concept C = true;
17
- template<typename T> struct A {
18
- void f() requires C<42>; // #1
19
- void f() requires true; // OK, different functions
20
- };
21
- ```
22
-
23
- — *end example*]
24
-
25
- — *end note*]
26
-
27
- A function member of a derived class is *not* in the same scope as a
28
- function member of the same name in a base class.
29
-
30
- [*Example 2*:
31
-
32
- ``` cpp
33
- struct B {
34
- int f(int);
35
- };
36
-
37
- struct D : B {
38
- int f(const char*);
39
- };
40
- ```
41
-
42
- Here `D::f(const char*)` hides `B::f(int)` rather than overloading it.
43
-
44
- ``` cpp
45
- void h(D* pd) {
46
- pd->f(1); // error:
47
- // D::f(const char*) hides B::f(int)
48
- pd->B::f(1); // OK
49
- pd->f("Ben"); // OK, calls D::f
50
- }
51
- ```
52
-
53
- — *end example*]
54
-
55
- A locally declared function is not in the same scope as a function in a
56
- containing scope.
57
-
58
- [*Example 3*:
59
-
60
- ``` cpp
61
- void f(const char*);
62
- void g() {
63
- extern void f(int);
64
- f("asdf"); // error: f(int) hides f(const char*)
65
- // so there is no f(const char*) in this scope
66
- }
67
-
68
- void caller () {
69
- extern void callee(int, int);
70
- {
71
- extern void callee(int); // hides callee(int, int)
72
- callee(88, 99); // error: only callee(int) in scope
73
- }
74
- }
75
- ```
76
-
77
- — *end example*]
78
-
79
- Different versions of an overloaded member function can be given
80
- different access rules.
81
-
82
- [*Example 4*:
83
-
84
- ``` cpp
85
- class buffer {
86
- private:
87
- char* p;
88
- int size;
89
- protected:
90
- buffer(int s, char* store) { size = s; p = store; }
91
- public:
92
- buffer(int s) { p = new char[size = s]; }
93
- };
94
- ```
95
-
96
- — *end example*]
97
-