[#LLVM_MARK_AS_BITMASK_ENUM]
= LLVM&lowbar;MARK&lowbar;AS&lowbar;BITMASK&lowbar;ENUM
:mrdocs:

LLVM&lowbar;MARK&lowbar;AS&lowbar;BITMASK&lowbar;ENUM lets you opt in an individual enum type so you can perform bitwise operations on it without putting static&lowbar;cast everywhere&period;

== Synopsis

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

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

----

== Description

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

void Foo() {
  MyEnum A = (E1 | E2) & E3 ^ ~E4; // Look, ma: No static_cast!
}
----
Normally when you do a bitwise operation on an enum value, you get back an instance of the underlying type (e&period;g&period; int)&period; But using this macro, bitwise ops on your enum will return you back instances of the enum&period; This is particularly useful for enums which represent a combination of flags&period;

All of the enum&apos;s values must be non&hyphen;negative&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *LargestValue*
| Largest individual enumerator value in the enum&period;
|===


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