Files
DNF_DEV/source/EngineFrame/Attribute/Bits.h

26 lines
639 B
C++

#pragma once
#include <type_traits>
namespace bits
{
template <typename _Ty>
inline void Set(_Ty &old, _Ty flag)
{
static_assert(std::is_arithmetic<_Ty>::value, "_Ty must be an arithmetic type");
old |= flag;
}
template <typename _Ty>
inline void Unset(_Ty &old, _Ty flag)
{
static_assert(std::is_arithmetic<_Ty>::value, "_Ty must be an arithmetic type");
old &= ~flag;
}
template <typename _Ty>
inline bool Has(_Ty old, _Ty flag)
{
static_assert(std::is_arithmetic<_Ty>::value, "_Ty must be an arithmetic type");
return !!(old & flag);
}
}