[PATCH] D81580: [ADT] Add Bitfield utilities

Pavel Kosov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 16 23:57:43 PDT 2020


kpdev42 added inline comments.


================
Comment at: llvm/include/llvm/ADT/Bitfields.h:90
+
+  static constexpr unsigned TypeBits = sizeof(Unsigned) * CHAR_BIT;
+  static_assert(TypeBits >= Bits, "n-bit must fit in T");
----------------
Maybe it is worth to use `std::numeric_limits<T>::digits` here?
Like this:
```
static constexpr auto TypeBits = std::numeric_limits<Unsigned>::digits;
```
then it will be possible to remove `#include <climits> // CHAR_BIT`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81580/new/

https://reviews.llvm.org/D81580





More information about the llvm-commits mailing list