|
|
@@ -17,8 +17,9 @@
|
|
|
#include <variant>
|
|
|
#include <vector>
|
|
|
|
|
|
-#if __has_include(<magic_enum.hpp>)
|
|
|
-#include <magic_enum.hpp>
|
|
|
+#if __has_include(<magic_enum/magic_enum.hpp>)
|
|
|
+#include <magic_enum/magic_enum.hpp>
|
|
|
+#include <magic_enum/magic_enum_flags.hpp>
|
|
|
#endif
|
|
|
|
|
|
#include "string_utils/any_of.h"
|
|
|
@@ -94,10 +95,15 @@ template <typename Out> bool cast(Out & out, std::string_view str) noexcept {
|
|
|
} else if constexpr (std::is_constructible_v<Out, std::string_view>) {
|
|
|
out = Out(str);
|
|
|
return true;
|
|
|
-#if __has_include(<magic_enum.hpp>)
|
|
|
+#if __has_include(<magic_enum/magic_enum.hpp>)
|
|
|
} else if constexpr (std::is_enum_v<Out>) {
|
|
|
- constexpr auto type = magic_enum::as_flags<magic_enum::detail::is_flags_v<Out>>;
|
|
|
- std::optional<Out> result = magic_enum::enum_cast<Out, type>(str);
|
|
|
+ std::optional<Out> result;
|
|
|
+ if constexpr (magic_enum::detail::subtype_v<Out> ==
|
|
|
+ magic_enum::detail::enum_subtype::flags) {
|
|
|
+ result = magic_enum::enum_flags_cast<Out>(str);
|
|
|
+ } else {
|
|
|
+ result = magic_enum::enum_cast<Out>(str);
|
|
|
+ }
|
|
|
out = result.value_or(out);
|
|
|
return result.has_value();
|
|
|
#endif
|