tmp/tmpa_4422q2/{from.md → to.md}
RENAMED
|
@@ -1,40 +1,39 @@
|
|
| 1 |
### Member functions <a id="class.mfct">[[class.mfct]]</a>
|
| 2 |
|
| 3 |
-
A member function may be defined
|
| 4 |
-
definition, in which case it is an
|
| 5 |
-
|
| 6 |
-
it has already been declared but not defined in
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
appearing outside of the class definition, a member function shall not
|
| 13 |
be redeclared.
|
| 14 |
|
| 15 |
-
An inline member function (whether static or non-static) may also be
|
| 16 |
-
defined outside of its class definition provided either its declaration
|
| 17 |
-
in the class definition or its definition outside of the class
|
| 18 |
-
definition declares the function as `inline` or `constexpr`.
|
| 19 |
-
|
| 20 |
-
[*Note 1*: Member functions of a class in namespace scope have the
|
| 21 |
-
linkage of that class. Member functions of a local class (
|
| 22 |
-
[[class.local]]) have no linkage. See [[basic.link]]. — *end note*]
|
| 23 |
-
|
| 24 |
[*Note 2*: There can be at most one definition of a non-inline member
|
| 25 |
-
function in a program. There may be more than one
|
| 26 |
-
|
| 27 |
[[dcl.inline]]. — *end note*]
|
| 28 |
|
|
|
|
|
|
|
|
|
|
| 29 |
If the definition of a member function is lexically outside its class
|
| 30 |
definition, the member function name shall be qualified by its class
|
| 31 |
name using the `::` operator.
|
| 32 |
|
| 33 |
-
[*Note
|
| 34 |
-
*parameter-declaration-clause* including the default arguments
|
| 35 |
-
[[dcl.fct.default]]
|
| 36 |
described in [[basic.lookup]]. — *end note*]
|
| 37 |
|
| 38 |
[*Example 1*:
|
| 39 |
|
| 40 |
``` cpp
|
|
@@ -53,21 +52,21 @@ type `T` refers to the typedef member `T` declared in class `X` and the
|
|
| 53 |
default argument `count` refers to the static data member `count`
|
| 54 |
declared in class `X`.
|
| 55 |
|
| 56 |
— *end example*]
|
| 57 |
|
| 58 |
-
[*Note
|
| 59 |
always refers to the same entity, whether or not the member function is
|
| 60 |
-
|
| 61 |
|
| 62 |
-
Previously declared member functions may be mentioned in
|
| 63 |
declarations.
|
| 64 |
|
| 65 |
Member functions of a local class shall be defined inline in their class
|
| 66 |
definition, if they are defined at all.
|
| 67 |
|
| 68 |
-
[*Note
|
| 69 |
|
| 70 |
A member function can be declared (but not defined) using a typedef for
|
| 71 |
a function type. The resulting member function has exactly the same type
|
| 72 |
as it would have if the function declarator were provided explicitly,
|
| 73 |
see [[dcl.fct]]. For example,
|
|
|
|
| 1 |
### Member functions <a id="class.mfct">[[class.mfct]]</a>
|
| 2 |
|
| 3 |
+
A member function may be defined [[dcl.fct.def]] in its class
|
| 4 |
+
definition, in which case it is an inline [[dcl.inline]] member function
|
| 5 |
+
if it is attached to the global module, or it may be defined outside of
|
| 6 |
+
its class definition if it has already been declared but not defined in
|
| 7 |
+
its class definition.
|
| 8 |
+
|
| 9 |
+
[*Note 1*: A member function is also inline if it is declared `inline`,
|
| 10 |
+
`constexpr`, or `consteval`. — *end note*]
|
| 11 |
+
|
| 12 |
+
A member function definition that appears outside of the class
|
| 13 |
+
definition shall appear in a namespace scope enclosing the class
|
| 14 |
+
definition. Except for member function definitions that appear outside
|
| 15 |
+
of a class definition, and except for explicit specializations of member
|
| 16 |
+
functions of class templates and member function templates [[temp.spec]]
|
| 17 |
appearing outside of the class definition, a member function shall not
|
| 18 |
be redeclared.
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
[*Note 2*: There can be at most one definition of a non-inline member
|
| 21 |
+
function in a program. There may be more than one inline member function
|
| 22 |
+
definition in a program. See [[basic.def.odr]] and
|
| 23 |
[[dcl.inline]]. — *end note*]
|
| 24 |
|
| 25 |
+
[*Note 3*: Member functions of a class have the linkage of the name of
|
| 26 |
+
the class. See [[basic.link]]. — *end note*]
|
| 27 |
+
|
| 28 |
If the definition of a member function is lexically outside its class
|
| 29 |
definition, the member function name shall be qualified by its class
|
| 30 |
name using the `::` operator.
|
| 31 |
|
| 32 |
+
[*Note 4*: A name used in a member function definition (that is, in the
|
| 33 |
+
*parameter-declaration-clause* including the default arguments
|
| 34 |
+
[[dcl.fct.default]] or in the member function body) is looked up as
|
| 35 |
described in [[basic.lookup]]. — *end note*]
|
| 36 |
|
| 37 |
[*Example 1*:
|
| 38 |
|
| 39 |
``` cpp
|
|
|
|
| 52 |
default argument `count` refers to the static data member `count`
|
| 53 |
declared in class `X`.
|
| 54 |
|
| 55 |
— *end example*]
|
| 56 |
|
| 57 |
+
[*Note 5*: A `static` local variable or local type in a member function
|
| 58 |
always refers to the same entity, whether or not the member function is
|
| 59 |
+
inline. — *end note*]
|
| 60 |
|
| 61 |
+
Previously declared member functions may be mentioned in friend
|
| 62 |
declarations.
|
| 63 |
|
| 64 |
Member functions of a local class shall be defined inline in their class
|
| 65 |
definition, if they are defined at all.
|
| 66 |
|
| 67 |
+
[*Note 6*:
|
| 68 |
|
| 69 |
A member function can be declared (but not defined) using a typedef for
|
| 70 |
a function type. The resulting member function has exactly the same type
|
| 71 |
as it would have if the function declarator were provided explicitly,
|
| 72 |
see [[dcl.fct]]. For example,
|