This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
YimMenu/src/util/misc.hpp

41 lines
640 B
C++
Raw Normal View History

#pragma once
namespace big::misc
{
template<typename T>
inline void clear_bit(T* address, int pos)
{
*address &= ~(1 << pos);
}
template<typename T>
inline void clear_bits(T* address, int bits)
{
*address &= ~(bits);
}
template<typename T>
inline bool has_bit_set(T* address, int pos)
{
return *address & 1 << pos;
}
template<typename T>
inline bool has_bits_set(T* address, T bits)
{
return (*address & bits) == bits;
}
template<typename T>
inline void set_bit(T* address, int pos)
{
*address |= 1 << pos;
}
template<typename T>
inline void set_bits(T* address, int bits)
{
*address |= bits;
}
}