Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enum_bitset initialization issue #19

Open
X-Ryl669 opened this issue Sep 18, 2024 · 1 comment
Open

enum_bitset initialization issue #19

X-Ryl669 opened this issue Sep 18, 2024 · 1 comment

Comments

@X-Ryl669
Copy link

You can use the underlying type as well:

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.

@dakka
Copy link
Member

dakka commented Oct 14, 2024

Thanks for your input. I'll look at implementing for the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants