谁能解释一下当前 C++0x 标准草案的这一段吗?
谁能解释 ISO N3242 §3.3.3 第 2 点中的这一说法
函数定义 (8.4) 中函数参数名称的潜在作用域(包括出现在 lambda 声明符中的)或函数局部预定义变量开始在其声明点。如果函数具有函数 try 块,则参数或函数局部预定义变量的潜在范围在最后一个关联处理程序的末尾结束,否则在函数定义的最外层块的末尾结束。不得在函数定义的最外层块或与函数 try 块关联的任何处理程序的最外层块中重新声明参数名称。
ISO 标准 2003 规定:
函数定义 (8.4) 中函数参数名称的潜在范围从其声明点开始。如果函数具有函数 try 块,则参数的潜在范围在最后一个关联处理程序的末尾结束,否则它将在函数定义的最外层块的末尾结束。不得在函数定义的最外层块或与函数 try 块关联的任何处理程序的最外层块中重新声明参数名称。
这些说法的实际区别是什么?
有人用示例/程序解释上面添加的一点吗?
我注意到它属于函数局部预定义变量他实际上在说什么..关于这个?
Can anyone explain this statement from ISO N3242 §3.3.3, 2nd point
The potential scope of a function parameter name (including one appearing in lambda-declarator) or of a function-local predefined variable in a function definition (8.4) begins at its point of declaration. If the function has a function-try-block the potential scope of a parameter or of a function-local predefined variable ends at the end of the last associated handler, otherwise it ends at the end of the outermost block of the function definition. A parameter name shall not be redeclared in the outermost block of the function definition nor in the outermost block of any handler associated with a function-try-block.
ISO Standard 2003 says:
The potential scope of a function parameter name in a function definition (8.4) begins at its point of declaration. If the function has a function-try-block the potential scope of a parameter ends at the end of the last associated handler, else it ends at the end of the outermost block of the function definition. A parameter name shall not be redeclared in the outermost block of the function definition nor in the outermost block of any handler associated with a function-try-block.
What is the actual difference in these statements?
Any one explain the above added point in terms of example/program...?
I noticed that it belongs to function-local predefined variable what actually he is saying .. there ,regarding this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这些更改是添加了“函数局部预定义变量”,这是 C++0x 中新增的内容。它们是隐式定义的静态变量,可在函数内使用。标准草案定义了一个名为
__func__
的函数,它给出了函数的名称,并允许实现添加更多自己的函数。本段现在说,无论函数参数名称在哪里,它们都可用。The changes are the addition of "function-local predefined variables", which are new to C++0x. They are implicitly defined static variables available for use within the function. The draft standard defines one called
__func__
which gives the name of the function, and allows implementations to add more of their own. This paragraph now says that they are available wherever the function parameter names are.