{"id":21984664,"url":"https://github.com/mrts/flag-set-cpp","last_synced_at":"2025-04-30T07:28:55.681Z","repository":{"id":55132407,"uuid":"212790960","full_name":"mrts/flag-set-cpp","owner":"mrts","description":"flag_set is a type-safe class for using enums as flags in C++","archived":false,"fork":false,"pushed_at":"2020-03-19T18:37:10.000Z","size":16,"stargazers_count":11,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T14:02:41.834Z","etag":null,"topics":["cpp","enums"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrts.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-04T10:35:22.000Z","updated_at":"2025-01-10T11:52:30.000Z","dependencies_parsed_at":"2022-08-14T13:00:24.070Z","dependency_job_id":null,"html_url":"https://github.com/mrts/flag-set-cpp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrts%2Fflag-set-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrts%2Fflag-set-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrts%2Fflag-set-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrts%2Fflag-set-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrts","download_url":"https://codeload.github.com/mrts/flag-set-cpp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251660094,"owners_count":21623191,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","enums"],"created_at":"2024-11-29T18:10:41.674Z","updated_at":"2025-04-30T07:28:55.650Z","avatar_url":"https://github.com/mrts.png","language":"C++","readme":"# flag-set-cpp\n\n`flag_set` is a type-safe class for using enums as flags in C++14 with an underlying `std::bitset`.\n\nThe original idea is by [Arnaud Kapp (Xaqq)](https://codereview.stackexchange.com/questions/96146/c-flagset-typesafe-usage-of-enumeration-as-bitset-bitmask)\nwith additions from \n[Barry Revzin](https://codereview.stackexchange.com/users/31292/barry).\n\n## Usage\n\n`flag_set` is a header-only library, simply copy `include/flag_set.hpp` to your\nproject to use it.\n\nThe `enum` type of the `flag_set` **must have** a last value sentinel `_`,\na single underscore character. Underscore was chosen as it stands out clearly and is\nunlikely to collide with a real enum value.\n\nUsage example:\n\n```c++\n#include \"flag_set.hpp\"\n\nenum class Options : uint8_t {\n    FULLSCREEN,\n    INVERT_MOUSE,\n    FLASH,\n    RED_BACKGROUND,\n    RED_FOREGROUND,\n    _\n};\n\nint main()\n{\n    flag_set\u003cOptions\u003e red(Options::RED_FOREGROUND | Options::RED_BACKGROUND);\n\n    if (red[Options::RED_BACKGROUND]) // or red \u0026 Options::RED_BACKGROUND\n        cout \u003c\u003c \"Red background activated\";\n}\n```\n\nSee more examples in [tests](tests/src/flag-set-tests.cpp).\n\n## Contributing\n\nRun `clang-format` on patches as follows:\n\n```sh\nfind include/ tests/ -iname '*.hpp' -o -iname '*.h' -o -iname '*.cpp' | xargs clang-format -i\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrts%2Fflag-set-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrts%2Fflag-set-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrts%2Fflag-set-cpp/lists"}