7
據我所知,在編譯時可以使用constexpr
變量。 例如對於模板或靜態asser。靜態const和constexpr變量有什麼區別?
但是如果我想這樣做沒有constexpr我可以用static const
。
什麼是因爲C++ 11引入constexpr的區別/ 14
之間constexpr int a = 3;
//AND
static const int a = 3;
謝謝!
看到這個問題的另一種方法是應該使用哪一種?
它非常依賴*你在哪裏*有聲明。靜態限定符在不同的地方做不同的事情。 –
'constexpr'也適用於非'int's。 –
@KerrekSB值得一提,'const'也是如此。 –