Skip to content

Commit b8fa720

Browse files
committed
P1682R2 std::to_underlying for enumerations
1 parent 4faf57e commit b8fa720

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

source/support.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,7 @@
684684
#define @\defnlibxname{cpp_lib_to_address}@ 201711L // also in \libheader{memory}
685685
#define @\defnlibxname{cpp_lib_to_array}@ 201907L // also in \libheader{array}
686686
#define @\defnlibxname{cpp_lib_to_chars}@ 201611L // also in \libheader{charconv}
687+
#define @\defnlibxname{cpp_lib_to_underlying}@ 202102L // also in \libheader{utility}
687688
#define @\defnlibxname{cpp_lib_transformation_trait_aliases}@ 201304L // also in \libheader{type_traits}
688689
#define @\defnlibxname{cpp_lib_transparent_operators}@ 201510L // also in \libheader{memory}, \libheader{functional}
689690
#define @\defnlibxname{cpp_lib_tuple_element_t}@ 201402L // also in \libheader{tuple}

source/utilities.tex

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@
9595
template<class R, class T>
9696
constexpr bool in_range(T t) noexcept;
9797

98+
// \ref{utility.underlying}, to_underlying
99+
template<class T>
100+
constexpr underlying_type_t<T> to_underlying(T value) noexcept;
101+
98102
// \ref{intseq}, compile-time integer sequences%
99103
\indexlibraryglobal{index_sequence}%
100104
\indexlibraryglobal{make_index_sequence}%
@@ -568,6 +572,19 @@
568572
\tcode{bool}.
569573
\end{note}
570574

575+
\rSec2[utility.underlying]{Function template \tcode{to_underlying}}
576+
577+
\begin{itemdecl}
578+
template<class T>
579+
constexpr underlying_type_t<T> to_underlying(T value) noexcept;
580+
\end{itemdecl}
581+
582+
\begin{itemdescr}
583+
\pnum
584+
\returns \tcode{static_cast<underlying_type_t<T>>(value)}.
585+
\end{itemdescr}
586+
587+
571588
\rSec1[intseq]{Compile-time integer sequences}
572589

573590
\rSec2[intseq.general]{In general}

0 commit comments

Comments
 (0)