it as value of postincrement never used, but I think it is false-positive
template<typename T, typename... Vs>
static T packBoolsIntoBitset(Vs... values)
{
static_assert(sizeof...(Vs) <= sizeof(T) * 8, "The type is too small");
T result = 0;
size_t bitIndex = 0;
((result |= (values << bitIndex++)), ...);
return result;
}
I guess I can do something like this, but it looks a bit more ugly
((result |= (++bitIndex, values << (bitIndex-1))), ...);
... causes the rhs of |= evaluate multiple times?
I do wonder why it's generic over value types if it is literally named "packBools"
Well, yes I should have restricted it to only bool types, didn't think about it yet :D
Обсуждают сегодня