最終更新:2021-01-07 (木) 15:46:32 (1202d)
constexpr
Top / constexpr
コンパイル時定数
- constexpr変数は、その初期値をコンパイル時に決定できなければなりません
- リテラル値や、constexpr が付いた他の定数を使って初期化できる
- constexpr は関数にも付けられます
定数式
- コンパイル時に定数となる変数・関数
constexpr変数
- コンパイル時定数
constexpr関数
- コンパイル時に関数を実行できるようになる
constexpr int square(int x){return x*x}; int ar[square(2)];