OMNI_VAL_HAS_FLAG_BIT
MACRO

OMNI_VAL_HAS_FLAG_BIT - Determines if a flag bit is set in a value

SYNOPSIS top

A helper macro used to determine if a bit flag is set within a specified value.

DESCRIPTION top

You can utilize this macro if you wish to test if a specific bit flag is set within a specified numeric value.

Example:
typedef struct enum_vals {
    typedef enum enum_t {
        VAL1 = 1, // 0001
        VAL2 = 2, // 0010
        VAL3 = 4, // 0100
        VAL4 = 8  // 1000
    } enum_t;
} enum_vals;

int i = 42; // 0010 1010
std::cout << "VAL2 " << (OMNI_VAL_HAS_FLAG_BIT(i, enum_vals::VAL2) ? "is" : "is NOT") << " set" << std::endl;
std::cout << "VAL3 " << (OMNI_VAL_HAS_FLAG_BIT(i, enum_vals::VAL3) ? "is" : "is NOT") << " set" << std::endl;
The output for this would be:
VAL2 is set
VAL3 is NOT set

CONSIDERATIONS top

No special considerations

PLATFORM SPECIFIC top

No platform specific notes.

NOTES top

None.