Closed Nerixyz closed 5 months ago
I would rather suggest you make your own namespaces with the necessary overloads
This is a quick example
namespace magic_enum8 {
template <typename E>
std::u8string enum_name(E v) {
std::u8string str;
auto n = magic_enum::enum_name<E>(v);
str.reserve(n.size());
for (auto c : n)
str.append(1, c);
return str;
}
}
namespace magic_enum16 {
template <typename E>
std::u16string enum_name(E v) {
std::u16string str;
auto n = magic_enum::enum_name<E>(v);
str.reserve(n.size());
for (auto c : n)
str.append(1, c);
return str;
}
}
Thank you, I made a small adaption for Qt's QString
and QStringView
. It only supports Latin1 characters, but that shouldn't really be a limitation in practice. It's mostly constexpr
except for getting QString
s. Should work on both Qt 6 and 5 (only tested on 6 right now).
Hi, thanks for the great library!
We're currently using
magic_enum
without any custom string type. Since we're using Qt, a lot of our strings are Utf-16, so we'd want to change the string type in these cases withMAGIC_ENUM_USING_ALIAS_STRING{,_VIEW}
to au16string
, however, other parts are using Utf-8. With templated code defined in headers, it's not really easy to ensure only one type is included (utf-8 or utf-16) or some files might want to use both.Would it be possible to allow users to modify the namespace of magic_enum? I suppose it's not that easy with the include-guards, but it would be nice to be able to have both
magic_enum8
andmagic_enum16
for example.