bit_util: Protect Replicate from automatic up-casting
Recursive calls to `Replicate` beyond the first call might cause an unintentional up-casting to an `int` type due to `|` and `<<` operations on types such as `uint8_t` and `uint16_t` This makes sure calls such as `Recursive<u8>` stay as the `u8` type through-out.
This commit is contained in:
parent
f171ce7859
commit
46b8cfabc0
1 changed files with 1 additions and 1 deletions
|
@ -203,7 +203,7 @@ constexpr T Replicate(T value, size_t element_size) {
|
|||
ASSERT_MSG(BitSize<T>() % element_size == 0, "bitsize of T not divisible by element_size");
|
||||
if (element_size == BitSize<T>())
|
||||
return value;
|
||||
return Replicate(value | (value << element_size), element_size * 2);
|
||||
return Replicate<T>(T(value | value << element_size), element_size * 2);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
Loading…
Reference in a new issue