scoped-enum-flags

🚩 A C++23 header-only type-safe bit flag manager for C++ scoped enumerations.(使用C++23开发的基于强类型枚举的标志位操作库。)

https://github.com/zhuagenborn/scoped-enum-flags

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (5.5%) to scientific vocabulary

Keywords

enum-flags scoped-enum
Last synced: 6 months ago · JSON representation ·

Repository

🚩 A C++23 header-only type-safe bit flag manager for C++ scoped enumerations.(使用C++23开发的基于强类型枚举的标志位操作库。)

Basic Info
  • Host: GitHub
  • Owner: Zhuagenborn
  • License: mit
  • Language: C++
  • Default Branch: main
  • Homepage:
  • Size: 8.79 KB
Statistics
  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Topics
enum-flags scoped-enum
Created over 1 year ago · Last pushed 9 months ago
Metadata Files
Readme License Citation

README.md

Scoped Enumeration Bit Flags

C++ CMake GitHub Actions License

Introduction

A header-only type-safe bit flag manager for C++ scoped enumerations written in C++23, supporting:

  • Setting and clearing individual or multiple flags.
  • Checking if any or multiple flags are set.
  • Combining multiple flags into a single flag.

Unit Tests

Prerequisites

  • Install GoogleTest.
  • Install CMake.

Building

Go to the project folder and run:

bash mkdir -p build cd build cmake -DENUM_FLAGS_BUILD_TESTS=ON .. cmake --build .

Running

Go to the build folder and run:

bash ctest -VV

Examples

See more examples in tests/enum_flags_tests.cpp.

c++ enum class Opt : unsigned int { A = EnumFlags<Opt>::CreateFlag(0), B = EnumFlags<Opt>::CreateFlag(1), C = EnumFlags<Opt>::CreateFlag(2), D = EnumFlags<Opt>::CreateFlag(3), E = EnumFlags<Opt>::CreateFlag(4) };

```c++ const EnumFlags flags {Opt::A, Opt::B, Opt::C}; EXPECTTRUE(flags & Opt::A); EXPECTFALSE(flags & Opt::D);

EXPECTTRUE(flags.HasAny({Opt::A, Opt::D})); EXPECTFALSE(flags.HasAny({Opt::D, Opt::E}));

EXPECTTRUE(flags.HasAll({Opt::A, Opt::B})); EXPECTTRUE((flags & EnumFlags {Opt::A, Opt::B})); EXPECTFALSE(flags.HasAll({Opt::C, Opt::D})); EXPECTFALSE((flags & EnumFlags {Opt::C, Opt::D})); ```

```c++ EnumFlags flags; EXPECTFALSE(flags & Opt::A); flags |= Opt::A; EXPECTTRUE(flags & Opt::A);

const auto newflags {flags | Opt::D}; EXPECTTRUE(new_flags & Opt::D); ```

c++ EnumFlags<Opt> flags {Opt::A, Opt::B, Opt::C}; EXPECT_TRUE(flags & Opt::C); flags.Remove(Opt::C); EXPECT_FALSE(flags & Opt::C);

License

Distributed under the MIT License. See LICENSE for more information.

Owner

  • Name: Zhuagenborn
  • Login: Zhuagenborn
  • Kind: organization
  • Location: Ireland

Software Development | Artificial Intelligence | Reverse Engineering.

Citation (CITATION.cff)

cff-version: 1.2.0
authors:
- family-names: Chen
  given-names: Zhenshuo
  orcid: https://orcid.org/0000-0003-2091-4160
- family-names: Liu
  given-names: Guowen
  orcid: https://orcid.org/0000-0002-8375-5729
title: C++ Scoped Enumeration Flags
date-released: 2024-09-29
url: https://github.com/Zhuagenborn/Scoped-Enum-Flags

GitHub Events

Total
  • Push event: 1
Last Year
  • Push event: 1

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 6
  • Total Committers: 1
  • Avg Commits per committer: 6.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 6
  • Committers: 1
  • Avg Commits per committer: 6.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Chenzs108 c****8@o****m 6

Issues and Pull Requests

Last synced: 8 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Dependencies

.github/workflows/cmake-gtest.yaml actions
  • actions/checkout main composite
  • actions/download-artifact main composite
  • actions/upload-artifact main composite