mirror of
https://github.com/Neargye/magic_enum.git
synced 2026-01-29 02:40:06 +00:00
Enable wchar_t as string_view value_type (#272)
This commit is contained in:
parent
fba99305d2
commit
8f6c9905fd
5 changed files with 190 additions and 22 deletions
|
|
@ -190,7 +190,7 @@ struct name_sort_impl<void, OP> {
|
|||
struct FullCmp : S {};
|
||||
|
||||
template <typename S>
|
||||
struct FullCmp<S, std::enable_if_t<!std::is_invocable_v<S, string_view, string_view> && std::is_invocable_v<S, char, char>>> {
|
||||
struct FullCmp<S, std::enable_if_t<!std::is_invocable_v<S, string_view, string_view> && std::is_invocable_v<S, char_type, char_type>>> {
|
||||
[[nodiscard]] constexpr inline bool operator()(string_view s1, string_view s2) const noexcept { return lexicographical_compare<S>(s1, s2); }
|
||||
};
|
||||
|
||||
|
|
@ -546,7 +546,7 @@ class bitset {
|
|||
}
|
||||
}
|
||||
|
||||
constexpr explicit bitset(detail::raw_access_t, string_view sv, string_view::size_type pos = 0, string_view::size_type n = string_view::npos, char zero = '0', char one = '1')
|
||||
constexpr explicit bitset(detail::raw_access_t, string_view sv, string_view::size_type pos = 0, string_view::size_type n = string_view::npos, char_type zero = '0', char_type one = '1')
|
||||
: a{{}} {
|
||||
std::size_t i{};
|
||||
for (auto c : sv.substr(pos, n)) {
|
||||
|
|
@ -562,8 +562,8 @@ class bitset {
|
|||
}
|
||||
}
|
||||
|
||||
constexpr explicit bitset(detail::raw_access_t, const char* str, std::size_t n = ~std::size_t{}, char zero = '0', char one = '1')
|
||||
: bitset(std::string_view{str, (std::min)(std::char_traits<char>::length(str), n)}, 0, n, zero, one) {}
|
||||
constexpr explicit bitset(detail::raw_access_t, const char_type* str, std::size_t n = ~std::size_t{}, char_type zero = '0', char_type one = '1')
|
||||
: bitset(std::string_view{str, (std::min)(std::char_traits<char_type>::length(str), n)}, 0, n, zero, one) {}
|
||||
|
||||
constexpr bitset(std::initializer_list<E> starters) : a{{}} {
|
||||
if constexpr (magic_enum::detail::subtype_v<E> == magic_enum::detail::enum_subtype::flags) {
|
||||
|
|
@ -591,7 +591,7 @@ class bitset {
|
|||
}
|
||||
|
||||
template <typename Cmp = std::equal_to<>>
|
||||
constexpr explicit bitset(string_view sv, Cmp&& cmp = {}, char sep = '|') {
|
||||
constexpr explicit bitset(string_view sv, Cmp&& cmp = {}, char_type sep = '|') {
|
||||
for (std::size_t to{}; (to = magic_enum::detail::find(sv, sep)) != string_view::npos; sv.remove_prefix(to + 1)) {
|
||||
if (auto v = enum_cast<E>(sv.substr(0, to), cmp)) {
|
||||
set(v);
|
||||
|
|
@ -756,7 +756,7 @@ class bitset {
|
|||
return res;
|
||||
}
|
||||
|
||||
[[nodiscard]] string to_string(char sep = '|') const {
|
||||
[[nodiscard]] string to_string(char_type sep = '|') const {
|
||||
string name;
|
||||
|
||||
for (auto& e : enum_values<E>()) {
|
||||
|
|
@ -771,7 +771,7 @@ class bitset {
|
|||
return name;
|
||||
}
|
||||
|
||||
[[nodiscard]] string to_string(detail::raw_access_t, char zero = '0', char one = '1') const {
|
||||
[[nodiscard]] string to_string(detail::raw_access_t, char_type zero = '0', char_type one = '1') const {
|
||||
string name;
|
||||
name.reserve(size());
|
||||
for (std::size_t i{}; i < size(); ++i) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue