Hey, I wanted to write some code with bit operations and didnt want to use <bitset> because i tested it with some bit operations and its turned to be slower than just using these operations on simple int or longlong
Lets get to the question!
I created these 2 functios just for the readability of the code and I read that 1 guy told that function call dont affect speed much because compiler generates equal code to that if I didnt call function but used just full code instead. So here are my 2 funtions
template <class I, class I2, class B>
inlinevoid change_bit_T(I& val, I2 num, B bitval){
val = (val & ~(1 << num)) | (bitval << num);
}
Now when I tested them in for loop turned out that simple val = (val & ~(1 << num)) | (bitval << num); worked 7 times faster than when I called any of these functions. Is that normal?
Thanks for answer man!
No I haven't, its all in default mode, I'm using VS 2013. Will have to check how to turn it on
That's probably it, can close this topic :) Thanks a lot!