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.
- Host: GitHub
- URL: https://github.com/astrodynamic/flags
- Owner: Astrodynamic
- License: mit
- Created: 2025-02-26T22:10:44.000Z (11 months ago)
- Default Branch: develop
- Last Pushed: 2025-03-01T20:11:05.000Z (10 months ago)
- Last Synced: 2025-03-01T20:35:25.863Z (10 months ago)
- Topics: bit-manipulation, bitflags, bits, bitset, cmake, cpp, cpp17, enums, header-only, library, performance, software-development, utilities, utility-library
- Language: C++
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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).