Add clear_bit and set_bit.

This commit is contained in:
joevt 2023-09-18 16:07:42 -07:00 committed by dingusdev
parent 3bea3ec3d8
commit 3062a29b78
1 changed files with 10 additions and 0 deletions

View File

@ -78,4 +78,14 @@ static inline bool bit_set(const uint64_t val, const int bit_num) {
return !!(val & (1ULL << bit_num));
}
template <class T>
inline void clear_bit(T &val, const int bit_num) {
val &= ~((T)1 << bit_num);
}
template <class T>
inline void set_bit(T &val, const int bit_num) {
val |= ((T)1 << bit_num);
}
#endif // BIT_OPS_H