Index: llvm/docs/CodingStandards.rst =================================================================== --- llvm/docs/CodingStandards.rst +++ llvm/docs/CodingStandards.rst @@ -1026,6 +1026,21 @@ The idea is to reduce indentation and the amount of code you have to keep track of when reading the code. +Note: this advice does not apply to a ``constexpr if`` statement. The +substatement of the ``else`` clause may be a discarded statement, so removing +the ``else`` can cause unexpected template instantiations. Thus, the following +example is correct: + +.. code-block:: c++ + + template + static int foo(Ty T) { + if constexpr (std::is_integral_v) + return 10 + T; + else + return 100; + } + Turn Predicate Loops into Predicate Functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^