File tree Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change 1644
1644
\grammarterm {parameter-declaration}{} this
1645
1645
\grammarterm {initializer-clause}{}
1646
1646
is used as a default argument.
1647
- Default arguments will be used in calls where trailing arguments are missing.
1647
+ \begin {note }
1648
+ Default arguments will be used in calls
1649
+ where trailing arguments are missing\iref {expr.call }.
1650
+ \end {note }
1648
1651
1649
1652
\pnum
1650
1653
\indextext {argument!example of default}%
1709
1712
In
1710
1713
a given function declaration, each parameter subsequent to a
1711
1714
parameter with a default argument shall have a default argument
1712
- supplied in this or a previous declaration
1715
+ supplied in this or a previous declaration,
1716
+ unless the parameter was expanded from a parameter pack,
1713
1717
or shall be a function parameter pack.
1714
1718
A default argument
1715
1719
shall not be redefined by a later declaration (not even to the
1735
1739
void n() {
1736
1740
f(6); // OK, calls \tcode {f(6, 7)}
1737
1741
}
1742
+ template<class ... T> struct C {
1743
+ void f(int n = 0, T...);
1744
+ };
1745
+ C<int> c; // OK, instantiates declaration \tcode {void C::f(int n = 0, int)}
1738
1746
\end {codeblock }
1739
1747
\end {example }
1740
1748
For a given inline function defined in different translation units,
Original file line number Diff line number Diff line change 2237
2237
\indextext {function argument|see{argument}}%
2238
2238
\indextext {function parameter|see{parameter}}%
2239
2239
\indextext {initialization!parameter}%
2240
- When a function is called, each parameter\iref {dcl.fct } shall be
2240
+ When a function is called, each parameter\iref {dcl.fct } is
2241
2241
initialized~(\ref {dcl.init }, \ref {class.copy }, \ref {class.ctor }) with
2242
2242
its corresponding argument.
2243
+ If there is no corresponding argument,
2244
+ the default argument for the parameter is used;
2245
+ the program is ill-formed if one is not present.
2246
+ \begin {example }
2247
+ \begin {codeblock }
2248
+ template<typename ...T> int f(int n = 0, T ...t);
2249
+ int x = f<int>(); // error: no argument for second function parameter
2250
+ \end {codeblock }
2251
+ \end {example }
2243
2252
If the function is a non-static member
2244
2253
function, the \tcode {this} parameter of the function\iref {class.this }
2245
- shall be initialized with a pointer to the object of the call, converted
2254
+ is initialized with a pointer to the object of the call, converted
2246
2255
as if by an explicit type conversion\iref {expr.cast }.
2247
2256
\begin {note }
2248
2257
There is no access or ambiguity checking on this conversion; the access
You can’t perform that action at this time.
0 commit comments