1
0
Fork 0
mirror of https://github.com/Neargye/magic_enum.git synced 2026-01-09 23:34:23 +00:00

Add enum fusing function (#127)

This commit is contained in:
Pavel I. Kryukov 2022-02-10 20:58:59 +03:00 committed by GitHub
parent 22242a613a
commit 1f8e29b140
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 87 additions and 0 deletions

View file

@ -32,6 +32,7 @@ Header-only C++17 library provides static reflection for enums, work with any en
* `enum_index` obtains index in enum value sequence from enum value.
* `enum_contains` checks whether enum contains enumerator with such value.
* `enum_type_name` returns name of enum type.
* `enum_fuse` allows multidimensional switch/cases.
* `is_unscoped_enum` checks whether type is an [Unscoped enumeration](https://en.cppreference.com/w/cpp/language/enum#Unscoped_enumeration).
* `is_scoped_enum` checks whether type is an [Scoped enumeration](https://en.cppreference.com/w/cpp/language/enum#Scoped_enumerations).
* `underlying_type` improved UB-free "SFINAE-friendly" [underlying_type](https://en.cppreference.com/w/cpp/types/underlying_type).
@ -136,6 +137,16 @@ enum class Color { RED = 2, BLUE = 4, GREEN = 8 };
// color_entries[0].first -> Color::RED
// color_entries[0].second -> "RED"
```
* Enum fusion for multi-level switch/case statements
```cpp
switch (magic_enum::enum_fuse(color1, color2)) {
case magic_enum::enum_fuse(RED, BLUE): // ...
case magic_enum::enum_fuse(RED, RED): // ...
// ...
}
```
* Ostream operator for enum