I was wondering how to do this:
func(param1|param2|param3)
and then extract those values in the function, I have seen this in multiple functions, or is it better to do this:
func(param1, ...)
?
I am trying to do this in C++, and I was thinking of having the parameters to the function as values in a enum.
How do I solve this?
Param1, param2, param3 are usually defined as a numbers with different bits turned on.
|is an operator of bitwise alternative, that means it works on separate bits.In example:
When you pass an argument to function you make a bitwise alternative of earlier defined params.
In function, you don’t make a decomposition, but check if a specified bit is set on, using bitwise conjunction: