6
Basic concepts
[basic]
6.7
Storage duration
[basic.stc]
6.7.1
Static storage duration
[basic.stc.static]
1
#
All variables which do not have dynamic storage duration, do not have thread storage duration, and are not local have
static storage duration
.
The storage for these entities shall last for the duration of the program (
[basic.start.static]
,
[basic.start.term]
)
.
2
#
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]
.
3
#
The keyword
static
can be used to declare a local variable with static storage duration
.
[
Note
:
[stmt.dcl]
describes the initialization of local
static
variables;
[basic.start.term]
describes the destruction of local
static
variables
.
—
end note
]
4
#
The keyword
static
applied to a class data member in a class definition gives the data member static storage duration
.