What does if constexpr discard, and which syntax or name checks still apply to the discarded branch?
Show answer and explanation
The condition of if constexpr is a constant expression. In a templated context, once it is no longer value-dependent, the unselected substatement is discarded and templates or return statements used only there need not be instantiated for that specialization. The source must still parse, and non-dependent names and errors that cannot be valid for any specialization can still be diagnosed; outside a templated context, an unselected branch is checked normally rather than acting like a preprocessor directive. Use it to select type-dependent implementation, not to hide arbitrary invalid source.
The condition of if constexpr is a constant expression. In a templated context, once it is no longer value-dependent, the unselected substatement is discarded and templates or return statements used only there need not be instantiated for that specialization. The source must still parse, and non-dependent names and errors that cannot be valid for any specialization can still be diagnosed; outside a templated context, an unselected branch is checked normally rather than acting like a preprocessor directive. Use it to select type-dependent implementation, not to hide arbitrary invalid source.
Connect the conclusion directly to the type, lifetime, ownership, overload-resolution rule, or library contract present in the question. State implementation dependence or a violated precondition explicitly instead of merely guessing output.