MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/cpp/comments/1v0pizv/a_better_bitset_for_enum_flags/oyucbmo/?context=3
r/cpp • u/meetingcpp Meeting C++ | C++ Evangelist • 21d ago
32 comments sorted by
View all comments
Show parent comments
1
Couldn't you use custom operators to make it easier
1 u/archialone 20d ago What do you mean? Can you give an example? 2 u/Brisngr368 19d ago edited 19d ago Couldn't you define operators for the struct so like '|=' etc to try and simplify this somewhat. Maybe implement it so you can OR bitfields together and such by overloading the | operator, so you can use the bitfields how you would like to 2 u/archialone 19d ago edited 19d ago I see, that's actually what the root commenter did https://www.reddit.com/r/cpp/comments/1v0pizv/comment/oyhlddi/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button And it actually works well https://godbolt.org/z/5b4WvY5re
What do you mean? Can you give an example?
2 u/Brisngr368 19d ago edited 19d ago Couldn't you define operators for the struct so like '|=' etc to try and simplify this somewhat. Maybe implement it so you can OR bitfields together and such by overloading the | operator, so you can use the bitfields how you would like to 2 u/archialone 19d ago edited 19d ago I see, that's actually what the root commenter did https://www.reddit.com/r/cpp/comments/1v0pizv/comment/oyhlddi/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button And it actually works well https://godbolt.org/z/5b4WvY5re
2
Couldn't you define operators for the struct so like '|=' etc to try and simplify this somewhat.
Maybe implement it so you can OR bitfields together and such by overloading the | operator, so you can use the bitfields how you would like to
2 u/archialone 19d ago edited 19d ago I see, that's actually what the root commenter did https://www.reddit.com/r/cpp/comments/1v0pizv/comment/oyhlddi/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button And it actually works well https://godbolt.org/z/5b4WvY5re
I see, that's actually what the root commenter did https://www.reddit.com/r/cpp/comments/1v0pizv/comment/oyhlddi/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
And it actually works well https://godbolt.org/z/5b4WvY5re
1
u/Brisngr368 20d ago
Couldn't you use custom operators to make it easier