{"id":13418371,"url":"https://github.com/aantron/better-enums","last_synced_at":"2025-05-15T14:08:42.592Z","repository":{"id":31880594,"uuid":"35449048","full_name":"aantron/better-enums","owner":"aantron","description":"C++ compile-time enum to string, iteration, in a single header file","archived":false,"fork":false,"pushed_at":"2024-02-10T16:50:13.000Z","size":592,"stargazers_count":1754,"open_issues_count":50,"forks_count":180,"subscribers_count":56,"default_branch":"master","last_synced_at":"2025-05-09T16:02:17.354Z","etag":null,"topics":["cpp","enum","header-only","reflection"],"latest_commit_sha":null,"homepage":"http://aantron.github.io/better-enums","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aantron.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"aantron"}},"created_at":"2015-05-11T20:44:15.000Z","updated_at":"2025-05-07T05:44:43.000Z","dependencies_parsed_at":"2024-01-18T11:13:29.973Z","dependency_job_id":"3b0e67d4-e6e1-47f3-8a4c-3929143561e8","html_url":"https://github.com/aantron/better-enums","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aantron%2Fbetter-enums","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aantron%2Fbetter-enums/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aantron%2Fbetter-enums/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aantron%2Fbetter-enums/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aantron","download_url":"https://codeload.github.com/aantron/better-enums/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254355335,"owners_count":22057354,"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","enum","header-only","reflection"],"created_at":"2024-07-30T22:01:01.537Z","updated_at":"2025-05-15T14:08:37.502Z","avatar_url":"https://github.com/aantron.png","language":"C++","funding_links":["https://github.com/sponsors/aantron"],"categories":["TODO scan for Android support in followings","Reflection","Coding","映射","Miscellaneous","C++"],"sub_categories":["c++","物理学"],"readme":"# Better Enums \u0026nbsp; [![Try online][wandbox-img]][wandbox] [![Travis status][travis-img]][travis] [![AppVeyor status][appveyor-img]][appveyor]\n\n[wandbox]:      http://melpon.org/wandbox/permlink/2QCi3cwQnplAToge\n[wandbox-img]:  https://img.shields.io/badge/try%20it-online-blue.svg\n[appveyor]:     https://ci.appveyor.com/project/aantron/better-enums/branch/master\n[travis]:       https://travis-ci.org/aantron/better-enums/branches\n[travis-img]:   https://img.shields.io/travis/aantron/better-enums/master.svg?label=travis\n[appveyor-img]: https://img.shields.io/appveyor/ci/aantron/better-enums/master.svg?label=appveyor\n[license-img]:  https://img.shields.io/badge/license-BSD-lightgrey.svg\n\nReflective compile-time enum library with clean syntax, in a single header\nfile, and without dependencies.\n\n![Better Enums code overview][sample]\n\n[sample]: https://raw.githubusercontent.com/aantron/better-enums/master/doc/image/sample.gif\n\nIn C++11, *everything* can be used at compile time. You can convert your enums,\nloop over them, [find their max][max],\n[statically enforce conventions][enforce], and pass along the results as\ntemplate arguments or to `constexpr` functions. All the reflection is available\nfor your metaprogramming needs.\n\nThe interface is the same for C++98 \u0026mdash; you just have to use most of it at\nrun time only. This library does provide scoped and sized enums, something not\nbuilt into C++98.\n\nSee the [project page][project] for full documentation.\n\n[max]:      http://aantron.github.io/better-enums/demo/BitSets.html\n[enforce]:  http://aantron.github.io/better-enums/demo/SpecialValues.html\n[project]:  http://aantron.github.io/better-enums\n\n\u003cbr/\u003e\n\n## Installation\n\nSimply add `enum.h` to your project.\n\n\u003cbr/\u003e\n\n## Additional features\n\n- Uses only standard C++, though, for C++98, variadic macro support is required\n  (major compilers have it).\n- Supported and tested on [clang, gcc, and msvc][testing].\n- Fast compilation. You have to declare a few dozen enums to slow down your\n  compiler as much as [only including `iostream` does][performance].\n- Use any initializers and sparse ranges, just like with a built-in enum.\n- Control over size and alignment \u0026mdash; you choose the representation type.\n- Stream operators.\n- Does not use the heap and can be compiled with exceptions disabled, for use in\n  minimal freestanding environments.\n\n[testing]:     http://aantron.github.io/better-enums/CompilerSupport.html\n[performance]: http://aantron.github.io/better-enums/Performance.html\n\n\u003cbr/\u003e\n\n## Limitations\n\n1. The biggest limitation is that the `BETTER_ENUM` macro can't be used inside a\nclass. This seems [difficult to remove][nested]. There is a workaround with\n`typedef` (or C++11 `using`):\n\n    ```c++\n    BETTER_ENUM(SomePrefix_Color, uint8_t, Red, Green, Blue)\n\n    struct triplet {\n        typedef SomePrefix_Color    Color;\n        Color                       r, g, b;\n    };\n\n    triplet::Color  color;\n    ```\n\n    You can, however, use `BETTER_ENUM` inside a namespace.\n\n2. The macro has a soft limit of 64 declared constants. You can extend it by\nfollowing [these instructions][extend]. Ultimately, the number of constants is\nlimited by your compiler's maximum macro argument count.\n\n3. In some cases, it is necessary to prefix constants such as `Channel::Red` with a\n`+` to explicitly promote them to type `Channel`. For example, if you are doing\na comparison:\n\n    ```c++\n    channel == +Channel::Red\n    ```\n\n4. On msvc, you may need to enable [warning C4062][C4062] to get `switch` case exhaustiveness checking.\n\n[nested]: http://aantron.github.io/better-enums/DesignDecisionsFAQ.html#NoEnumInsideClass\n[extend]: http://aantron.github.io/better-enums/ExtendingLimits.html\n[C4062]: https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-4-c4062\n\n\u003cbr/\u003e\n\n## History\n\nThe original version of the library was developed by the author in the winter of\n2012-2013 at Hudson River Trading, as a replacement for an older generator\ncalled `BETTER_ENUM`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faantron%2Fbetter-enums","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faantron%2Fbetter-enums","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faantron%2Fbetter-enums/lists"}