在函数体内部使用 static constexpr
和 constexpr
有什么区别吗?
int SomeClass::get(const bool b)
{
static constexpr int SOME_CONSTANT = 3;
constexpr int SOME_OTHER_CONSTANT = 5;
if(b)
return SOME_CONSTANT;
else
return SOME_OTHER_CONSTANT;
}
constexpr
变量表现出一定的特性,static
变量也是如此。 - Drew Dormannconstexpr
函数中声明,那么一切都会不同。 - Caglayan DOKME