<cuda/std/bit>#
2026-10-07
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.
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.