template<typename E, \
typename = decltype (is_offset_type (std::declval<E> ()))> \
constexpr E \
operator OP (E lhs, typename std::underlying_type<E>::type rhs) \
{ \
using underlying = typename std::underlying_type<E>::type; \
return (E) (static_cast<underlying> (lhs) OP rhs); \
} \
\
template<typename E, \
typename = decltype (is_offset_type (std::declval<E> ()))> \
constexpr E \
operator OP (typename std::underlying_type<E>::type lhs, E rhs) \
{ \
using underlying = typename std::underlying_type<E>::type; \
return (E) (lhs OP static_cast<underlying> (rhs)); \
} \
\
template<typename E, \
typename = decltype (is_offset_type (std::declval<E> ()))> \
E & \
operator OP ## = (E &lhs, typename std::underlying_type<E>::type rhs) \
{ \
using underlying = typename std::underlying_type<E>::type; \
lhs = (E) (static_cast<underlying> (lhs) OP rhs); \
return lhs; \
}