Commit 0b0cf58f authored by BogDan Vatra's avatar BogDan Vatra

We already know the underlying_type.

We just need to pass it to DEFINE_BITMASK_OPERATORS macro
parent 7d1f372b
......@@ -1485,21 +1485,17 @@ volatile __attribute__((weak)) const char *flatbuffer_version_string =
#endif // !defined(_WIN32) && !defined(__CYGWIN__)
#define DEFINE_BITMASK_OPERATORS(E)\
#define DEFINE_BITMASK_OPERATORS(E, T)\
inline E operator | (E lhs, E rhs){\
using T = std::underlying_type<E>::type;\
return E(T(lhs) | T(rhs));\
}\
inline E operator & (E lhs, E rhs){\
using T = std::underlying_type<E>::type;\
return E(T(lhs) & T(rhs));\
}\
inline E operator ^ (E lhs, E rhs){\
using T = std::underlying_type<E>::type;\
return E(T(lhs) ^ T(rhs));\
}\
inline E operator ~ (E lhs){\
using T = std::underlying_type<E>::type;\
return E(~T(lhs));\
}\
inline E operator |= (E &lhs, E rhs){\
......
......@@ -184,7 +184,7 @@ static void GenEnum(const Parser &parser, EnumDef &enum_def,
code += GenEnumVal(enum_def, maxv->name, parser.opts) + "\n";
code += "};\n";
if (parser.opts.scoped_enums && enum_def.attributes.Lookup("bit_flags"))
code += "DEFINE_BITMASK_OPERATORS(" + enum_def.name + ")\n";
code += "DEFINE_BITMASK_OPERATORS(" + enum_def.name + ", " + GenTypeBasic(enum_def.underlying_type, false) + ")\n";
code += "\n";
// Generate a generate string table for enum values.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment