| 1 |
// PR c++/53567 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
|
| 4 |
template <unsigned int, bool> struct IntegerType { typedef unsigned type; }; |
| 5 |
|
| 6 |
template <class EnumT> |
| 7 |
using UnderlyingEnumType = typename IntegerType<sizeof(EnumT), (EnumT(-1) > EnumT(0))>::type; |
| 8 |
|
| 9 |
template <class EnumT, class UnderlyingT = UnderlyingEnumType<EnumT>> |
| 10 |
struct EnumMask |
| 11 |
{ |
| 12 |
constexpr EnumMask(EnumT val) : m_val(val) {} |
| 13 |
operator EnumT() { return m_val; } |
| 14 |
|
| 15 |
EnumT m_val; |
| 16 |
}; |
| 17 |
|
| 18 |
enum class A : unsigned { x }; |
| 19 |
|
| 20 |
template <class EnumT> |
| 21 |
EnumMask<EnumT> operator ~(EnumT lhs) |
| 22 |
{ |
| 23 |
return EnumT(~unsigned(lhs) & unsigned(EnumT::maskAll)); // { dg-error "not a member" } |
| 24 |
|
| 25 |
} |
| 26 |
|
| 27 |
int main() |
| 28 |
{ |
| 29 |
~A::x; |
| 30 |
return 0; |
| 31 |
} |