I have some code which needs to check if a bit in a bit field is set. I've been impressed with how optimized std::bitset.count compiles down, so thought this would be a good use of it as well. I'm surprised that when I use bitset.test, the compiler is still checking for exceptions, even when I add noexcept.
I have other checks to ensure that I won't test a bit which is out of range. Is there anything else I can do to optimize this code?
bool bitset_test(int n, size_t m) noexcept {
// The caller already verifies m is within range
return std::bitset<64>( n ).test( m );
}
Compiled output: https://godbolt.org/g/uRggXD