Path: blob/main/contrib/llvm-project/libcxx/include/__utility/to_underlying.h
35236 views
// -*- C++ -*-1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//89#ifndef _LIBCPP___UTILITY_TO_UNDERLYING_H10#define _LIBCPP___UTILITY_TO_UNDERLYING_H1112#include <__config>13#include <__type_traits/underlying_type.h>1415#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16# pragma GCC system_header17#endif1819_LIBCPP_BEGIN_NAMESPACE_STD2021#ifndef _LIBCPP_CXX03_LANG22template <class _Tp>23_LIBCPP_HIDE_FROM_ABI constexpr typename underlying_type<_Tp>::type __to_underlying(_Tp __val) noexcept {24return static_cast<typename underlying_type<_Tp>::type>(__val);25}26#endif // !_LIBCPP_CXX03_LANG2728#if _LIBCPP_STD_VER >= 2329template <class _Tp>30[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr underlying_type_t<_Tp> to_underlying(_Tp __val) noexcept {31return std::__to_underlying(__val);32}33#endif3435_LIBCPP_END_NAMESPACE_STD3637#endif // _LIBCPP___UTILITY_TO_UNDERLYING_H383940