为什么arter constexpr const示波器变量隐含静态?
(按照这个问题 :)
void foo() {
constexpr const auto my_lambda = [](int z) { return z+1; };
}
显然,my_lambda
is不是静态的”。从什么意义上讲,它不是静态的,除了没有官方定义是什么?为什么不应该隐式静态,看看它如何 a>?
(Following to this question:)
void foo() {
constexpr const auto my_lambda = [](int z) { return z+1; };
}
Apparently, my_lambda
is "not static". In what sense is it not-static, other than not officially defined to be? Why should it not be implicitly static, seeing how it seems to meet the definition?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
,因为它没有静态存储持续时间。它具有自动存储持续时间。
出于大多数目的,存储持续时间是否静态都无关紧要,因为对象的初始化和破坏是微不足道的,并且根本不使用存储。尽管如此,这表明了一个重要的区别:
Its not static in the sense that it doesn't have static storage duration. It has automatic storage duration.
For most purposes, it doesn't matter whether the storage duration is static or not because the initialisation and destruction of the object are trivial, and the storage isn't used at all. Still, this demonstrates an important difference: