[libcxx-commits] [libcxx] [libc++] Simplify __bitset::__init (PR #121357)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Wed Feb 26 06:32:49 PST 2025


https://github.com/philnik777 commented:

I think instead of trying to simplify the C++03 code, we should look into removing `__init` entirely and replace the code with something like
```c++
bitset(unsigned long long __v) : vals() {
        vals[0] = static_cast<size_t>(__v);
  if (sizeof(size_t) == 4) {
    __first_[1] = _Size >= 2 * __bits_per_word
                   ? static_cast<size_t>(__v >> __bits_per_word)
                   : static_cast<size_t>((__v >> __bits_per_word) &
                          (__storage_type(1) << (_Size - __bits_per_word)) - 1);
  }
}
```


https://github.com/llvm/llvm-project/pull/121357


More information about the libcxx-commits mailing list