If
本文对C++中的if
进行总结,它并不仅仅局限于if
statement,而是站在一个更高的角度来看待C++中的if
。
cppreference if statement
Used where code needs to be executed based on a run-time or compile-time condition.
NOTE:
run-time condition run-time/dynamic if: if
compile-time condition compile-time/static if: constexpr if
If Statements with Initializer (since C++17)
Constexpr If (since C++17)
NOTE: 这是C++17的主要新特性,在后面对它进行了详细介绍。