[llvm] [STLExtras] Backport std::to_underlying from C++23 (PR #70681)

Jakub Kuderski via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 30 10:45:40 PDT 2023


================
@@ -1535,6 +1535,13 @@ constexpr decltype(auto) makeVisitor(CallableTs &&...Callables) {
   return detail::Visitor<CallableTs...>(std::forward<CallableTs>(Callables)...);
 }
 
+/// Backport of C++23 std::to_underlying.
+template <typename Enum>
+[[nodiscard]] constexpr typename std::underlying_type_t<Enum>
+to_underlying(Enum E) {
+  return static_cast<typename std::underlying_type_t<Enum>>(E);
----------------
kuhar wrote:

do we need the `typename` here?

https://github.com/llvm/llvm-project/pull/70681


More information about the llvm-commits mailing list