You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
enum_bitset b(0,1,2,3);
std::cout << b << '\n';
[...]
You can use an int initialiser too:
enum_bitset b(15);
std::cout << b << '\n';
This interface will lead to bugs, IMHO because it mixes bit fields with bit number. Let's say you want to create a bitset with only the third bit set, you'll write enum_bitset<numbers> b(3) expecting 0b1000 but you'll get 0b00011 instead as the other constructor will kick in.
I think the interface to set the bit individually should use a initializer list enum_bitset<numbers> b({3}) so there's no possible confusion or you should remove the "default int" constructor (which should better be default unsigned) making it explicit with a typecast enum_bitset<numbers> b(conjure::bitmask(15)) so no possible confusion can happen.
The text was updated successfully, but these errors were encountered:
This interface will lead to bugs, IMHO because it mixes bit fields with bit number. Let's say you want to create a bitset with only the third bit set, you'll write
enum_bitset<numbers> b(3)
expecting0b1000
but you'll get0b00011
instead as the other constructor will kick in.I think the interface to set the bit individually should use a initializer list
enum_bitset<numbers> b({3})
so there's no possible confusion or you should remove the "default int" constructor (which should better be default unsigned) making it explicit with a typecastenum_bitset<numbers> b(conjure::bitmask(15))
so no possible confusion can happen.The text was updated successfully, but these errors were encountered: