namespace bitmasks_lib
{
std::false_type enableBitMaskOperators(type_tag<T>);
// use the result of this function as SFINAE predicate
template<typename T>
constexpr bool bitmaskOperatorsEnabled()
{
using bitmasks_lib::enableBitMaskOperators;
return decltype(enableBitMaskOperators(type_tag<T>()))::value;
}
}
#define ENABLE_BITMASK_OPERATORS(T) std::true_type enableBitMaskOperators(type_tag<T>);
// usage:
namespace mynamespace
{
enum class MyBitmap
{
...
};
ENABLE_BITMASK_OPERATORS(MyBitmap)
}