This commit is contained in:
neargye
2026-02-27 20:46:19 +04:00
parent 9c986e5db8
commit 1110266151
5 changed files with 44 additions and 19 deletions
+7
View File
@@ -54,6 +54,13 @@ int main() {
std::cout << "EatsFish|CanFly = " << magic_enum::enum_integer(f2.value()) << std::endl; // CanFly|EatsFish = 1074790400
}
// String name to enum-flags value with custom separator.
auto f2_custom = magic_enum::enum_flags_cast<AnimalFlags>("EatsFish,CanFly", ',');
if (f2_custom.has_value()) {
// Custom separator for enum-flags name.
std::cout << magic_enum::enum_flags_name(f2_custom.value(), ',') << " = " << magic_enum::enum_integer(f2_custom.value()) << std::endl; // CanFly,EatsFish = 1074790400
}
// Integer value to enum-flags value.
auto f3 = magic_enum::enum_cast<AnimalFlags>(1073742848);
if (f3.has_value()) {