22
General utilities library
[utilities]
22.2
Utility components
[utility]
22.2.9
Function
unreachable
[utility.unreachable]
🔗
[
[
noreturn
]
]
void
unreachable
(
)
;
1
#
Preconditions
:
false
is
true
.
[
Note
1
:
This precondition cannot be satisfied, thus the behavior of calling
unreachable
is undefined
.
—
end note
]
2
#
[
Example
1
:
int
f
(
int
x
)
{
switch
(
x
)
{
case
0
:
case
1
:
return
x;
default
:
std
::
unreachable
(
)
;
}
}
int
a
=
f
(
1
)
;
// OK,
a
has value
1
int
b
=
f
(
3
)
;
// undefined behavior
—
end example
]