1 2 3 | #define SET_BIT(MASK, Bit) (( MASK ) |= (0x01 << (Bit) )) #define CLEAR_BIT(MASK, Bit) (( MASK ) &= ~(0x01 << (Bit) )) #define TOGGLE_BIT(MASK, Bit) (( MASK ) ^= (0x01 << (Bit) )) |
1 2 3 4 | bool IsBit ( uint32& mask, const uint32 maskFlag ) { return !!(mask & maskFlag); } void SetBit ( uint32& mask, const uint32 maskFlag ) { mask |= (maskFlag); } void ClearBit ( uint32& mask, const uint32 maskFlag ) { mask &= ~(maskFlag); } void ToggleBit( uint32& mask, const uint32 maskFlag ) { mask ^= (maskFlag); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #define BIT(x) (1<<(x)) template < typename T > inline bool IsBit( const T& x, const T& bitFlag) { return !!(x & bitFlag); } template < typename T > inline void SetBit(T& x, const T& bitFlag) { x = static_cast < T >(x | bitFlag); } template < typename T > inline void ClearBit(T& x, const T& bitFlag) { x = static_cast < T >(x & (~bitFlag)); } template < typename T > inline void ToggleBit(T& x, const T& bitFlag) { x = static_cast < T >(x ^ bitFlag); } |
덧글을 달아 주세요