An open API service indexing awesome lists of open source software.

https://github.com/astrodynamic/flags

Simple C++ header-only bit flag library. Uses enum for type-safe, efficient flag manipulation.
https://github.com/astrodynamic/flags

bit-manipulation bitflags bits bitset cmake cpp cpp17 enums header-only library performance software-development utilities utility-library

Last synced: 10 months ago
JSON representation

Simple C++ header-only bit flag library. Uses enum for type-safe, efficient flag manipulation.

Awesome Lists containing this project

README

          

The `Flags` library provides a convenient way to work with bit flags using enums as indexes. It is based on `std::bitset` and provides an interface adapted for working with enums.

## Requirements

* C++17
* CMake 3.28.3 or higher

## Usage

To use the library, the `flags.h` header file must be included.
```cpp
#include "flags.h"
```

## Example

```cpp
enum class MyFlags {
Flag1,
Flag2,
Flag3,
COUNT
};

utils::Flags flags;

flags.set(MyFlags::Flag1);
flags.flip(MyFlags::Flag2);

if (flags[MyFlags::Flag1]) {
// ...
}
```

## Build

CMake is used to build the library.

```bash
cmake -S . -B build
cmake --build build
```

## LICENSE

This project is licensed under the [MIT License](LICENSE).