Skip to content

Commit 0156704

Browse files
committed
update proecess_enums.h inlining the use of _BITMASK_OPS since the number of arguments is changeing and I see no obvious way to control which version is used
1 parent 874e559 commit 0156704

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

include/modern_win32/process_enums.h

+35-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,41 @@ namespace modern_win32 {
150150
synchronize = SYNCHRONIZE,
151151
};
152152

153-
_BITMASK_OPS(process_access_rights);
153+
// formally _BITMASK_OPS(process_access_rights) but the definition of the macro changed without any obvious
154+
// flag to control which version is used.
155+
156+
MODERN_WIN32_EXPORT [[nodiscard]] constexpr process_access_rights operator&(
157+
process_access_rights left, process_access_rights right) noexcept {
158+
using integer_type = std::underlying_type_t<process_access_rights>;
159+
return static_cast<process_access_rights>(static_cast<integer_type>(left) & static_cast<integer_type>(right));
160+
}
161+
162+
MODERN_WIN32_EXPORT [[nodiscard]] constexpr process_access_rights operator|(process_access_rights left, process_access_rights right) noexcept {
163+
using integer_type = std::underlying_type_t<process_access_rights>;
164+
return static_cast<process_access_rights>(static_cast<integer_type>(left) | static_cast<integer_type>(right));
165+
}
166+
167+
MODERN_WIN32_EXPORT [[nodiscard]] constexpr process_access_rights operator^(process_access_rights left, process_access_rights right) noexcept {
168+
using integer_type = std::underlying_type_t<process_access_rights>;
169+
return static_cast<process_access_rights>(static_cast<integer_type>(left) ^ static_cast<integer_type>(right));
170+
}
171+
172+
MODERN_WIN32_EXPORT constexpr process_access_rights& operator&=(process_access_rights& left, process_access_rights right) noexcept {
173+
return left = left & right;
174+
}
175+
176+
MODERN_WIN32_EXPORT constexpr process_access_rights& operator|=(process_access_rights& left, process_access_rights right) noexcept {
177+
return left = left | right;
178+
}
179+
180+
MODERN_WIN32_EXPORT constexpr process_access_rights& operator^=(process_access_rights& left, process_access_rights right) noexcept {
181+
return left = left ^ right;
182+
}
183+
184+
MODERN_WIN32_EXPORT [[nodiscard]] constexpr process_access_rights operator~(process_access_rights left) noexcept {
185+
using integer_type = std::underlying_type_t<process_access_rights>;
186+
return static_cast<process_access_rights>(~static_cast<integer_type>(left));
187+
}
154188

155189
/// <summary>
156190
/// https://docs.microsoft.com/en-us/windows/win32/procthread/process-creation-flags

0 commit comments

Comments
 (0)