如果我有一个函数(比方说,一个大阵列)内的变量,它是有意义的声明它既static
和constexpr
?constexpr
保证数组是在编译时创建的,那么它会static
没用吗?
void f() {
static constexpr int x [] = {
// a few thousand elements
};
// do something with the array
}
Run Code Online (Sandbox Code Playgroud)
static
在生成的代码或语义方面,实际上是在做什么吗?