gpt4 book ai didi

c++ - 命名空间 -`static` 在 C++11 中是否仍被弃用?

转载 作者:IT老高 更新时间:2023-10-28 21:53:06 25 4
gpt4 key购买 nike

Possible Duplicate:
Deprecation of the static keyword… no more?

在 C++2003 中,不推荐使用命名空间-static:

[C++03: 7.3.1.1/2]: The use of the static keyword is deprecated when declaring objects in a namespace scope (see annex D); the unnamed-namespace provides a superior alternative.

我在 C++2011 中找不到任何此类子句存在的位置(建议弃用),并且 7.1.1 似乎并没有禁止命名空间-static (如果有,这表明该功能最终已从语言中删除);但是,C.2 中没有列出这两种情况(其中列出了 2003 年和 2011 年之间的显着差异)。

namespace-static 是否被弃用?

最佳答案

不推荐使用的命名空间-staticproposed and accepted for n3296 :

ID: FI 6
Ref: D.2 [depr.static] ¶ Paragraph 1
Comment: The use of static in namespace scope should not be deprecated. Anonymous namespaces are not a sufficient replacement for the functionality.
Proposed Resolution: Strike [depr.static] completely.
Owner: CWG
Issue: 1012
Disposition: ACCEPTED

事实上,条款 C(关于兼容性)没有列出对条款 D(关于弃用)所做的任何更改,因此很难“一目了然”。 但是,不,命名空间-static 在 C++11 中不再被弃用。

关于c++ - 命名空间 -`static` 在 C++11 中是否仍被弃用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8460191/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com