Hey guys!
Since I need to use flags, but don't want to restrict myself to a maximum number of flags (Depending on the type I use: char, int, etc), I thought about creating some kind of templated
(First things first: I don't know much about all that bitwise stuff)
Let's name my class "UFlag". How I want to be able to use it:
//Long way
UFlag<int> flag;
flag | 10 | 55;
if(flag & 10);
//do stuff. This will be true, obviously.
//But also on the fast way:
myMethodTakingUFLAGasArgument(UFlag<int> | 10 | 55) //Somehow like this, so that I don't have to declare my variable first...
...
void myMethodTakingUFLAGasArgument(UFlag<int> f){
UFlag<int> uf | 10; //I want also to be able to declare it like this... Saves one line.
if(f & uf) ;//do stuff. should be true with the example-argument above.
if(f & 55) ;//do stuff. should be true with the example-argument above.
}
Here is what I have right now: https://ideone.com/7jtnep
Unfortunately, not everything is working yet.
1 - I have not figured out yet how to apply the |/& operators in the same line as where I create the object.
2 - if checking doesnt work yet, as UFlag isnt a boolean.
How do I solve these two problems?
Kind regards,
Flyverse
Edit: Solved Problem#2.