If the value of the
converted condition is
false, the first substatement is a
discarded statement, otherwise the second substatement, if
present, is a discarded statement
. During the instantiation of an
enclosing templated entity (
[temp.pre]), if the condition is
not value-dependent after its instantiation, the discarded substatement
(if any) is not instantiated
. [
Note 1:
Odr-uses in a discarded statement do not require
an entity to be defined
. —
end note]
A
case or
default label appearing within such an
if statement shall be associated with a
switch
statement within the same
if statement
. A
label declared in a substatement of a constexpr if
statement shall only be referred to by a
statement in
the same substatement
. [
Example 1:
template<typename T, typename ... Rest> void g(T&& p, Rest&& ...rs) {
if constexpr (sizeof...(rs) > 0)
g(rs...);
}
extern int x;
int f() {
if constexpr (true)
return 0;
else if (x)
return x;
else
return -x;
}
—
end example]