2.2 KiB
[basic.stc.static]
6 Basics [basic]
6.8 Memory and objects [basic.memobj]
6.8.6 Storage duration [basic.stc]
6.8.6.2 Static storage duration [basic.stc.static]
All variables which
do not have thread storage duration and
belong to a namespace scope ([basic.scope.namespace]) or are first declared with the static or extern keywords ([dcl.stc])
The storage for these entities lasts for the duration of the program ([basic.start.static], [basic.start.term]).
If a variable with static storage duration has initialization or a destructor with side effects, it shall not be eliminated even if it appears to be unused, except that a class object or its copy/move may be eliminated as specified in [class.copy.elision].
[Note 1:
The keyword static can be used to declare a block variable ([basic.scope.block]) with static storage duration;[stmt.dcl] and [basic.start.term] describe the initialization and destruction of such variables.
The keyword static applied to a class data member in a class definition gives the data member static storage duration ([class.static.data]).
â end note]