CLIENT_MAIN
, CLIENT_DUMMY
(and CLIENT_CONTACT
).
Perhaps better names could be found, especially since Client
also
refers to the engine client ...GAMEINFOFLAG2_DDRACEHUD
std::filesystem
is also affected by this, but it's allowed by the c++ standard (?!)std::filesystem
is also affected by this, but it's allowed by the c++ standard (?!) You need to write your own overloaded operator| (and presumably operator& etc.).
Flags operator|(Flags lhs, Flags rhs)
{
return static_cast<Flags>(static_cast<char>(lhs) | static_cast<char>(rhs));
}
enum FLAGS_FOR_MYFUNCTION
{
FLAGS_NONE = 0x0,
FLAGS_DO_A_THING = 0x1,
FLAGS_DISABLE_A_THING = 0x2,
FLAGS_OPTIONAL_FEATURE = 0x4
};
constexpr inline T operator~ (T a) { return static_cast<T>( ~static_cast<std::underlying_type<T>::type>(a) ); }
constexpr inline T operator| (T a, T b) { return static_cast<T>( static_cast<std::underlying_type<T>::type>(a) | static_cast<std::underlying_type<T>::type>(b) ); }
constexpr inline T operator& (T a, T b) { return static_cast<T>( static_cast<std::underlying_type<T>::type>(a) & static_cast<std::underlying_type<T>::type>(b) ); }
constexpr inline T operator^ (T a, T b) { return static_cast<T>( static_cast<std::underlying_type<T>::type>(a) ^ static_cast<std::underlying_type<T>::type>(b) ); }
constexpr inline T& operator|= (T& a, T b) { return reinterpret_cast<T&>( reinterpret_cast<std::underlying_type<T>::type&>(a) |= static_cast<std::underlying_type<T>::type>(b) ); }
constexpr inline T& operator&= (T& a, T b) { return reinterpret_cast<T&>( reinterpret_cast<std::underlying_type<T>::type&>(a) &= static_cast<std::underlying_type<T>::type>(b) ); }
constexpr inline T& operator^= (T& a, T b) { return reinterpret_cast<T&>( reinterpret_cast<std::underlying_type<T>::type&>(a) ^= static_cast<std::underlying_type<T>::type>(b) ); }
HRESULT MyFunction(FLAGS_FOR_MYFUNCTION flags);
enum FLAGS_FOR_MYFUNCTION
{
FLAGS_NONE = 0x0,
FLAGS_DO_A_THING = 0x1,
FLAGS_DISABLE_A_THING = 0x2,
FLAGS_OPTIONAL_FEATURE = 0x4
};
constexpr inline T operator~ (T a) { return static_cast<T>( ~static_cast<std::underlying_type<T>::type>(a) ); }
constexpr inline T operator| (T a, T b) { return static_cast<T>( static_cast<std::underlying_type<T>::type>(a) | static_cast<std::underlying_type<T>::type>(b) ); }
constexpr inline T operator& (T a, T b) { return static_cast<T>( static_cast<std::underlying_type<T>::type>(a) & static_cast<std::underlying_type<T>::type>(b) ); }
constexpr inline T operator^ (T a, T b) { return static_cast<T>( static_cast<std::underlying_type<T>::type>(a) ^ static_cast<std::underlying_type<T>::type>(b) ); }
constexpr inline T& operator|= (T& a, T b) { return reinterpret_cast<T&>( reinterpret_cast<std::underlying_type<T>::type&>(a) |= static_cast<std::underlying_type<T>::type>(b) ); }
constexpr inline T& operator&= (T& a, T b) { return reinterpret_cast<T&>( reinterpret_cast<std::underlying_type<T>::type&>(a) &= static_cast<std::underlying_type<T>::type>(b) ); }
constexpr inline T& operator^= (T& a, T b) { return reinterpret_cast<T&>( reinterpret_cast<std::underlying_type<T>::type&>(a) ^= static_cast<std::underlying_type<T>::type>(b) ); }
HRESULT MyFunction(FLAGS_FOR_MYFUNCTION flags);
namespace FeatureFlag {
enum Flags : uint32_t {
debugAllocator = 0x1,
debugLogging = 0x2,
};
};
So that you can do FeatureFlag::debugAllocator
, otherwise if you don't rely on bitmasks you should prefer to use static_cast
, or some equivalent. Like I use
c++
template <typename EnumType> constexpr auto Idx(EnumType const & v) {
return static_cast<typename std::underlying_type<EnumType>::type>(v);
}
template <typename EnumType>
constexpr typename std::underlying_type<EnumType>::type & Idx(EnumType & v) {
return reinterpret_cast<typename std::underlying_type<EnumType>::type &>(v);
}
(edited)