我不明白 [dcl.fct.default]/3 中的最后一句话
I don't understand the last sentence in [dcl.fct.default]/3
[dcl.fct.default]/3(重点是我的):
A default argument shall be specified only in the
parameter-declaration-clause of a function declaration or
lambda-declarator or in a template-parameter (14.1); in the latter
case, the initializer-clause shall be an assignment-expression. A
default argument shall not be specified for a parameter pack. If it
is specified in a parameter-declaration-clause, it shall not occur
within a declarator or abstract-declarator of a
parameter-declaration.
上面的最后一句话说,如果在参数声明子句中指定了默认参数,它应该不会出现在参数的声明符或抽象声明符中-宣言。然而,当我查看参数声明的定义时,我在 [dcl.fct]/3 中找到以下内容(重点是我的):
parameter-declaration:
attribute-specifier-seqopt decl-specifier-seq
declarator
attribute-specifier-seqopt
decl-specifier-seq declarator = initializer-clause
attribute-specifier-seqopt decl-specifier-seq
abstract-declaratoropt
attribute-specifier-seqopt decl-specifier-seq
abstract-declaratoropt = initializer-clause
标准中有脚注
102) This means that default arguments cannot appear, for example, in
declarations of pointers to functions, references to functions, or
typedef declarations
例如这些声明
void f(void g(int = 10));
void ( *pf )(int = 10);
错了。
[dcl.fct.default]/3(重点是我的):
A default argument shall be specified only in the parameter-declaration-clause of a function declaration or lambda-declarator or in a template-parameter (14.1); in the latter case, the initializer-clause shall be an assignment-expression. A default argument shall not be specified for a parameter pack. If it is specified in a parameter-declaration-clause, it shall not occur within a declarator or abstract-declarator of a parameter-declaration.
上面的最后一句话说,如果在参数声明子句中指定了默认参数,它应该不会出现在参数的声明符或抽象声明符中-宣言。然而,当我查看参数声明的定义时,我在 [dcl.fct]/3 中找到以下内容(重点是我的):
parameter-declaration:
attribute-specifier-seqopt decl-specifier-seq declarator
attribute-specifier-seqopt decl-specifier-seq declarator = initializer-clause
attribute-specifier-seqopt decl-specifier-seq abstract-declaratoropt
attribute-specifier-seqopt decl-specifier-seq abstract-declaratoropt = initializer-clause
标准中有脚注
102) This means that default arguments cannot appear, for example, in declarations of pointers to functions, references to functions, or typedef declarations
例如这些声明
void f(void g(int = 10));
void ( *pf )(int = 10);
错了。