[#LLVM_DECLARE_ENUM_AS_BITMASK]
= LLVM&lowbar;DECLARE&lowbar;ENUM&lowbar;AS&lowbar;BITMASK
:mrdocs:

LLVM&lowbar;DECLARE&lowbar;ENUM&lowbar;AS&lowbar;BITMASK can be used to declare an enum type as a bit set, so that bitwise operation on such enum does not require static&lowbar;cast&period;

== Synopsis

Declared in `&lt;llvm&sol;ADT&sol;BitmaskEnum&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
#define LLVM&lowbar;DECLARE&lowbar;ENUM&lowbar;AS&lowbar;BITMASK(Enum, LargestValue)

----

== Description

[,cpp]
----
enum MyEnum { E1 = 1, E2 = 2, E3 = 4, E4 = 8 };
LLVM_DECLARE_ENUM_AS_BITMASK(MyEnum, E4);

void Foo() {
  MyEnum A = (E1 | E2) & E3 ^ ~E4; // No static_cast
}
----
The second parameter to LLVM&lowbar;DECLARE&lowbar;ENUM&lowbar;AS&lowbar;BITMASK specifies the largest bit value of the enum type&period;

LLVM&lowbar;DECLARE&lowbar;ENUM&lowbar;AS&lowbar;BITMASK should be used in llvm namespace&period;

This a non&hyphen;intrusive alternative for LLVM&lowbar;MARK&lowbar;AS&lowbar;BITMASK&lowbar;ENUM&period; It allows declaring more than one non&hyphen;scoped enumerations as bitmask types in the same scope&period; Otherwise it provides the same functionality as LLVM&lowbar;MARK&lowbar;AS&lowbar;BITMASK&lowbar;ENUM&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *Enum*
| Enum type to declare as a bitmask&period;
| *LargestValue*
| Largest individual enumerator value in `Enum&period;`
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
