| 310 | |
| 311 | template <class TTraits> |
| 312 | class TBitMapOps { |
| 313 | public: |
| 314 | using TChunk = typename TTraits::TChunk; |
| 315 | using TThis = TBitMapOps<TTraits>; |
| 316 | |
| 317 | private: |
| 318 | static_assert(std::is_unsigned<TChunk>::value, "expect std::is_unsigned<TChunk>::value"); |
| 319 | |
| 320 | static constexpr size_t BitsPerChunk = 8 * sizeof(TChunk); |
| 321 | static constexpr TChunk ModMask = static_cast<TChunk>(BitsPerChunk - 1); |
| 322 | static constexpr size_t DivCount = NBitMapPrivate::TDivCount<BitsPerChunk>::Value - 1; |
| 323 | static constexpr TChunk FullChunk = (TChunk)~TChunk(0); |
| 324 | |
| 325 | template <class> |
| 326 | friend class TBitMapOps; |
| 327 | |
| 328 | using TStorage = typename TTraits::TStorage; |
| 329 | |
| 330 | // The smallest unsigned type that can be used in bit ops |
| 331 | using TIntType = std::conditional_t<sizeof(TChunk) < sizeof(unsigned int), unsigned int, TChunk>; |
| 332 | |
| 333 | TStorage Mask; |
| 334 | |
| 335 | public: |
| 336 | class TReference { |
| 337 | private: |
| 338 | friend class TBitMapOps<TTraits>; |
| 339 | |
| 340 | TChunk* Chunk; |
| 341 | size_t Offset; |
| 342 | |
| 343 | TReference(TChunk* c, size_t offset) |
| 344 | : Chunk(c) |
| 345 | , Offset(offset) |
| 346 | { |
| 347 | } |
| 348 | |
| 349 | public: |
| 350 | ~TReference() = default; |
| 351 | |
| 352 | Y_FORCE_INLINE TReference& operator=(bool val) { |
| 353 | if (val) { |
| 354 | *Chunk |= static_cast<TChunk>(1) << Offset; |
| 355 | } else { |
| 356 | *Chunk &= ~(static_cast<TChunk>(1) << Offset); |
| 357 | } |
| 358 | |
| 359 | return *this; |
| 360 | } |
| 361 | |
| 362 | Y_FORCE_INLINE TReference& operator=(const TReference& ref) { |
| 363 | if (ref) { |
| 364 | *Chunk |= static_cast<TChunk>(1) << Offset; |
| 365 | } else { |
| 366 | *Chunk &= ~(static_cast<TChunk>(1) << Offset); |
| 367 | } |
| 368 | |
| 369 | return *this; |
nothing calls this directly
no test coverage detected