Updated comment in SetBits.
authorAndrew Woloszyn <awoloszyn@google.com>
Mon, 2 Nov 2015 20:45:29 +0000 (15:45 -0500)
committerDavid Neto <dneto@google.com>
Tue, 10 Nov 2015 20:57:07 +0000 (15:57 -0500)
It now mentions that it will fail if you try to set a bit that
does not exist.

include/util/bitutils.h

index 57dbd1f..370a432 100644 (file)
@@ -44,6 +44,8 @@ Dest BitwiseCast(Src source) {
 // SetBits<T, First, Num> returns an integer of type <T> with bits set
 // for position <First> through <First + Num - 1>, counting from the least
 // significant bit. In particular when Num == 0, no positions are set to 1.
+// A static assert will be triggered if First + Num > sizeof(T) * 8, that is,
+// a bit that will not fit in the underlying type is set.
 template <typename T, size_t First = 0, size_t Num = 0>
 struct SetBits {
   static_assert(First < sizeof(T) * 8,