15#ifndef GPUCOMMONBITSET_H
16#define GPUCOMMONBITSET_H
27#ifndef GPUCA_GPUCODE_DEVICE
36 static_assert(N <= 32,
"> 32 bits not supported");
45 static constexpr uint32_t
full_set = ((1ul << N) - 1ul);
49 GPUd() constexpr
bool none()
const {
return !any(); }
53 GPUd() constexpr
void reset() {
v = 0; }
54 GPUd() constexpr
void reset(uint32_t
i) {
v &= ~(1u <<
i); }
65 GPUd() constexpr bitset& operator&=(const bitset
b)
70 GPUd() constexpr bitset operator^(const bitset
b)
const {
return v ^
b.v; }
71 GPUd() constexpr bitset& operator^=(const bitset
b)
76 GPUd() constexpr bitset operator~()
const {
return (~
v) &
full_set; }
77 GPUd() constexpr
bool operator==(const bitset
b)
const {
return v ==
b.v; }
78 GPUd() constexpr
bool operator!=(const bitset
b)
const {
return v !=
b.v; }
80 GPUd() constexpr
bool operator[](uint32_t
i)
const {
return (
v >>
i) & 1u; }
82 GPUd() constexpr uint32_t to_ulong()
const {
return v; }
87 return GPUCommonMath::Popcount(
v);
90#ifndef GPUCA_GPUCODE_DEVICE
97 ClassDefNV(bitset, 1);
100#ifndef GPUCA_GPUCODE_DEVICE
105 for (uint32_t
i = N;
i--;) {
110template <
class CharT,
class Traits, u
int32_t N>
111std::basic_ostream<CharT, Traits>&
operator<<(std::basic_ostream<CharT, Traits>& os,
const bitset<N>&
x)
static constexpr uint32_t full_set
GPUd() const expr void reset()
GPUd() const expr void reset(uint32_t i)
GPUd() const expr void flip()
GPUdDefault() const expr bitset &operator
GPUd() const expr bitset(uint32_t vv)
GPUd() const expr void set()
GPUd() const expr bool none() const
GPUd() const expr bool all() const
GPUd() const expr bool any() const
GPUdDefault() const expr bitset()=default
GPUd() const expr bitset &operator|
GPUd() const expr void set(uint32_t i)
GLboolean GLboolean GLboolean b
std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > &os, const bitset< N > &x)
std::string to_string(gsl::span< T, Size > span)