24

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

In C++2003, namespace-static is deprecated:

[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.

I can't find where any such clause exists in C++2011 (suggesting undeprecation), and 7.1.1 doesn't seem to prohibit namespace-static (and if it had, this would suggest that the feature had been finally removed from the language); however, neither case is listed in C.2 (which itemises significant differences between 2003 and 2011).

Was namespace-static undeprecated or not?

Community
  • 1
  • 1
Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055

1 Answers1

16

Undeprecating namespace-static was proposed 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

In fact, clause C (on compatibility) does not list any changes made to clause D (on deprecation), so it's hard to tell "at a glance". But, no, namespace-static is no longer deprecated in C++11.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055