Go to the documentation of this file.
15 #ifndef GRPC_CORE_LIB_GPRPP_BITSET_H
16 #define GRPC_CORE_LIB_GPRPP_BITSET_H
23 #include <type_traits>
27 #if __cplusplus > 201103l
28 #define GRPC_BITSET_CONSTEXPR_MUTATOR constexpr
30 #define GRPC_BITSET_CONSTEXPR_MUTATOR
37 template <
size_t kBits>
58 template <
size_t kBits>
68 return total_bits <= 8 ? 8
69 : total_bits <= 16 ? 16
70 : total_bits <= 24 ? 8
71 : total_bits <= 32 ? 32
72 : total_bits <= 48 ? 16
73 : total_bits <= 64 ? 64
74 : total_bits <= 96 ? 32
83 template <
size_t kTotalBits,
86 static constexpr
size_t kUnits = (kTotalBits + kUnitBits - 1) / kUnitBits;
118 if (kTotalBits % kUnitBits == 0) {
129 for (
size_t i = 0;
i <
kUnits - 1;
i++) {
139 if (
units_[
i] != 0)
return false;
160 template <
typename Int>
162 (
sizeof(
Int) * 8 >= kTotalBits),
166 for (
size_t i = 0;
i < kTotalBits;
i++) {
174 static constexpr
size_t unit_for(
size_t bit) {
return bit / kUnitBits; }
204 bool all()
const {
return true; }
205 bool none()
const {
return true; }
211 #endif // GRPC_CORE_LIB_GPRPP_BITSET_H
GRPC_BITSET_CONSTEXPR_MUTATOR void set(int i)
GRPC_BITSET_CONSTEXPR_MUTATOR void set(int i, bool is_set)
static constexpr Uint< kUnitBits > mask_for(size_t bit)
GRPC_BITSET_CONSTEXPR_MUTATOR void clear(int i)
typename UintSelector< kBits >::Type Uint
constexpr bool is_set(int i) const
unsigned __int64 uint64_t
bool operator==(const BitSet &other) const
static constexpr Uint< kUnitBits > n_ones(size_t n)
constexpr size_t ChooseUnitBitsForBitSet(size_t total_bits)
std::enable_if< std::is_unsigned< Int >::value &&(sizeof(Int) *8 >=kTotalBits), Int >::type ToInt() const
static constexpr size_t unit_for(size_t bit)
static constexpr size_t kUnits
constexpr uint32_t BitCount(uint32_t i)
#define GRPC_BITSET_CONSTEXPR_MUTATOR
Uint< kUnitBits > units_[kUnits]
static constexpr Uint< kUnitBits > all_ones()
grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:39