<cuda/std/bit>#
2026-10-23
1 min read time
This page documents <cuda/std/bit> in libhipcxx, which provides the C++ Standard Library bit manipulation
functions, such as popcount, rotl, rotr, and bit_width, in host and device code.
cuda::std::bit_cast#
cuda::std::bit_cast extended the standard std::bit_cast to also recognize the HIP extended floating-point scalar and vector types as trivially copyable.
Limitations
The function can be used in
constexprcontexts only when the source and destination types are trivially copyable.The function cannot be used in
constexprcontexts with MSVC <= 19.25 and GCC <= 10.
Notes#
All functions are marked
[[nodiscard]]andnoexcept.All functions support 128-bit integer types.
bit_ceil()checks for overflow in debug mode.rotl()/rotr()checks for invalid count value (INT_MIN) in debug mode.The functions are
constexpr: for compile-time inputs libhipcxx evaluates them with a portable implementation, so the compiler folds them. For runtime inputs in device code it dispatches to the HIP device intrinsics, such as__popcforpopcount()and__clzforcountl_zero(), whilebyteswap()uses__builtin_bswap32.