modernize-use-std-bit¶
Finds common idioms which can be replaced by standard functions from the
<bit> C++20 header.
Covered scenarios:
Expression |
Replacement |
|
|
|
|
|
|
|
|
|
|
|
|
Options¶
- HonorIntPromotion¶
When set to
true(default isfalse), insert explicit cast to make sure the type of the substituted expression is unchanged. Example:// Return type is deduced as 'int' (not 'unsigned char') due to implicit conversions. auto foo(unsigned char x) { return x << 3 | x >> 5; }
Becomes:
#include <bit> auto foo(unsigned char x) { return static_cast<int>(std::rotl(x, 3)); }