Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport to_underlying #2853

Merged
merged 9 commits into from
Nov 19, 2024
10 changes: 1 addition & 9 deletions libcudacxx/include/cuda/std/__utility/to_underlying.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,11 @@

_LIBCUDACXX_BEGIN_NAMESPACE_STD

template <class _Tp>
_LIBCUDACXX_HIDE_FROM_ABI constexpr typename underlying_type<_Tp>::type __to_underlying(_Tp __val) noexcept
{
return static_cast<typename underlying_type<_Tp>::type>(__val);
}

#if _CCCL_STD_VER > 2020
template <class _Tp>
_CCCL_NODISCARD _LIBCUDACXX_HIDE_FROM_ABI constexpr underlying_type_t<_Tp> to_underlying(_Tp __val) noexcept
{
return _CUDA_VSTD::__to_underlying(__val);
return static_cast<underlying_type_t<_Tp>>(__val);
}
#endif

_LIBCUDACXX_END_NAMESPACE_STD

Expand Down
5 changes: 3 additions & 2 deletions libcudacxx/include/cuda/std/version
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
# include <ciso646> // otherwise go for the smallest possible header
#endif // !_CCCL_COMPILER(NVRTC)

#define __cccl_lib_to_underlying 202102L

#if _CCCL_STD_VER >= 2014
# define __cccl_lib_bit_cast 201806L
# define __cccl_lib_chrono_udls 201304L
Expand Down Expand Up @@ -244,8 +246,7 @@
// # define __cccl_lib_stdatomic_h 202011L
// # define __cccl_lib_string_contains 202011L
// # define __cccl_lib_string_resize_and_overwrite 202110L
# define __cccl_lib_to_underlying 202102L
# define __cccl_lib_unreachable 202202L
# define __cccl_lib_unreachable 202202L

#endif // _CCCL_STD_VER >= 2023

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// UNSUPPORTED: c++11
davebayer marked this conversation as resolved.
Show resolved Hide resolved

// [utility.underlying], to_underlying
// template <class T>
// constexpr underlying_type_t<T> to_underlying( T value ) noexcept; // C++2b
// constexpr underlying_type_t<T> to_underlying( T value ) noexcept;

#include <cuda/std/cassert>
#include <cuda/std/cstdint>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20

// [utility.underlying], to_underlying
// template <class T>
// constexpr underlying_type_t<T> to_underlying( T value ) noexcept; // C++2b
// constexpr underlying_type_t<T> to_underlying( T value ) noexcept;

#include <cuda/std/utility>

Expand Down