File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 706
706
#define @\defnlibxname {cpp_lib_type_trait_variable_templates}@ 201510L // also in \libheader {type_traits}
707
707
#define @\defnlibxname {cpp_lib_uncaught_exceptions}@ 201411L // also in \libheader {exception}
708
708
#define @\defnlibxname {cpp_lib_unordered_map_try_emplace}@ 201411L // also in \libheader {unordered_map}
709
+ #define @\defnlibxname {cpp_lib_unreachable}@ 202202L // also in \libheader {utility}
709
710
#define @\defnlibxname {cpp_lib_unwrap_ref}@ 201811L // also in \libheader {type_traits}
710
711
#define @\defnlibxname {cpp_lib_variant}@ 202106L // also in \libheader {variant}
711
712
#define @\defnlibxname {cpp_lib_void_t}@ 201411L // also in \libheader {type_traits}
Original file line number Diff line number Diff line change 98
98
template<class T>
99
99
constexpr underlying_type_t<T> to_underlying(T value) noexcept;
100
100
101
+ // \ref{utility.unreachable}, unreachable
102
+ [[noreturn]] void unreachable();
103
+
101
104
// \ref{intseq}, compile-time integer sequences%
102
105
\indexlibraryglobal{index_sequence}%
103
106
\indexlibraryglobal{make_index_sequence}%
610
613
\tcode{static_cast<underlying_type_t<T>>(value)}.
611
614
\end{itemdescr}
612
615
616
+ \rSec2[utility.unreachable]{Function \tcode{unreachable}}
617
+
618
+ \indexlibraryglobal{unreachable}%
619
+ \begin{itemdecl}
620
+ [[noreturn]] void unreachable();
621
+ \end{itemdecl}
622
+
623
+ \begin{itemdescr}
624
+ \pnum
625
+ \expects
626
+ \tcode{false} is \tcode{true}.
627
+ \begin{note}
628
+ This precondition cannot be satisfied, thus the behavior
629
+ of calling \tcode{unreachable} is undefined.
630
+ \end{note}
631
+
632
+ \pnum
633
+ \begin{example}
634
+ \begin{codeblock}
635
+ int f(int x) {
636
+ switch (x) {
637
+ case 0:
638
+ case 1:
639
+ return x;
640
+ default:
641
+ std::unreachable();
642
+ }
643
+ }
644
+ int a = f(1); // OK, \tcode{a} has value \tcode{1}
645
+ int b = f(3); // undefined behavior
646
+ \end{codeblock}
647
+ \end{example}
648
+ \end{itemdescr}
613
649
614
650
\rSec1[intseq]{Compile-time integer sequences}
615
651
You can’t perform that action at this time.
0 commit comments