mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-12-03 08:46:19 +08:00
add small section to README
This commit is contained in:
@@ -228,6 +228,9 @@ This results in the following JSON string:
|
||||
{"pos_x":2.0,"pos_y":3.0,"shape":"square","color":"red|blue"}
|
||||
```
|
||||
|
||||
You can also directly convert between enumerator values and strings with `rfl::enum_to_string()` and `rfl::string_to_enum()`, or
|
||||
obtain list of enumerator name and value pairs with `rfl::get_enumerators<EnumType>()` or `rfl::get_enumerator_array<EnumType>()`.
|
||||
|
||||
## Algebraic data types
|
||||
|
||||
reflect-cpp supports Pydantic-style tagged unions, which allow you to form algebraic data types:
|
||||
|
||||
+1
-1
@@ -148,7 +148,7 @@ This works, because 16 + 256 + 512 + 1024 + 8192 = 10000. Flag enums are *always
|
||||
|
||||
## General-purpose enumeration utilities
|
||||
|
||||
reflect-cpp also allows you to directly convert between enumeration values and strings:
|
||||
reflect-cpp also allows you to directly convert between enumerator values and strings:
|
||||
|
||||
```cpp
|
||||
enum class Color { red, green, blue };
|
||||
|
||||
Reference in New Issue
Block a user