From eb40a5467207cbfce3217fcef052d90a37c17b53 Mon Sep 17 00:00:00 2001 From: xaphier Date: Fri, 29 Sep 2023 08:17:52 +0200 Subject: [PATCH] Add constexpr for bitmask operators (#8037) Co-authored-by: Derek Bailey --- include/flatbuffers/flatbuffers.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h index bc828a313..cbb0c530f 100644 --- a/include/flatbuffers/flatbuffers.h +++ b/include/flatbuffers/flatbuffers.h @@ -248,31 +248,31 @@ inline const char *flatbuffers_version_string() { // clang-format off #define FLATBUFFERS_DEFINE_BITMASK_OPERATORS(E, T)\ - inline E operator | (E lhs, E rhs){\ + inline FLATBUFFERS_CONSTEXPR_CPP11 E operator | (E lhs, E rhs){\ return E(T(lhs) | T(rhs));\ }\ - inline E operator & (E lhs, E rhs){\ + inline FLATBUFFERS_CONSTEXPR_CPP11 E operator & (E lhs, E rhs){\ return E(T(lhs) & T(rhs));\ }\ - inline E operator ^ (E lhs, E rhs){\ + inline FLATBUFFERS_CONSTEXPR_CPP11 E operator ^ (E lhs, E rhs){\ return E(T(lhs) ^ T(rhs));\ }\ - inline E operator ~ (E lhs){\ + inline FLATBUFFERS_CONSTEXPR_CPP11 E operator ~ (E lhs){\ return E(~T(lhs));\ }\ - inline E operator |= (E &lhs, E rhs){\ + inline FLATBUFFERS_CONSTEXPR_CPP11 E operator |= (E &lhs, E rhs){\ lhs = lhs | rhs;\ return lhs;\ }\ - inline E operator &= (E &lhs, E rhs){\ + inline FLATBUFFERS_CONSTEXPR_CPP11 E operator &= (E &lhs, E rhs){\ lhs = lhs & rhs;\ return lhs;\ }\ - inline E operator ^= (E &lhs, E rhs){\ + inline FLATBUFFERS_CONSTEXPR_CPP11 E operator ^= (E &lhs, E rhs){\ lhs = lhs ^ rhs;\ return lhs;\ }\ - inline bool operator !(E rhs) \ + inline FLATBUFFERS_CONSTEXPR_CPP11 bool operator !(E rhs) \ {\ return !bool(T(rhs)); \ }