thin-provisioning-tools/base/bits.h
2013-10-17 11:45:20 +01:00

27 lines
489 B
C++

#ifndef BASE_BITS_H
#define BASE_BITS_H
//----------------------------------------------------------------
namespace base {
template <typename T>
bool test_bit(T flag, unsigned bit) {
return flag & (1 << bit);
}
template <typename T>
void set_bit(T &flag, unsigned bit) {
flag = flag | (1 << bit);
}
template <typename T>
void clear_bit(T &flag, unsigned bit) {
flag = flag & ~(1 << bit);
}
}
//----------------------------------------------------------------
#endif