mirror of
https://github.com/Neargye/magic_enum.git
synced 2026-01-09 23:34:23 +00:00
Fix optional masos (#160)
This commit is contained in:
parent
b0c0e02bdc
commit
74123638d1
1 changed files with 4 additions and 4 deletions
|
|
@ -897,7 +897,7 @@ template <auto V>
|
|||
constexpr auto index = enum_index<std::decay_t<decltype(V)>>(V);
|
||||
static_assert(index.has_value(), "magic_enum::enum_index enum value does not have a index.");
|
||||
|
||||
return index.value();
|
||||
return *index;
|
||||
}
|
||||
|
||||
// Checks whether enum contains enumerator with such enum value.
|
||||
|
|
@ -929,7 +929,7 @@ template <typename E>
|
|||
constexpr optional<std::uintmax_t> fuse_one_enum(optional<std::uintmax_t> hash, E value) noexcept {
|
||||
if (hash.has_value()) {
|
||||
if (const auto index = enum_index(value); index.has_value()) {
|
||||
return (hash.value() << log2(enum_count<E>() + 1)) | index.value();
|
||||
return (*hash << log2(enum_count<E>() + 1)) | *index;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
|
|
@ -950,7 +950,7 @@ constexpr auto typesafe_fuse_enum(Es... values) noexcept {
|
|||
enum class enum_fuse_t : std::uintmax_t;
|
||||
const auto fuse = fuse_enum(values...);
|
||||
if (fuse.has_value()) {
|
||||
return optional<enum_fuse_t>{static_cast<enum_fuse_t>(fuse.value())};
|
||||
return optional<enum_fuse_t>{static_cast<enum_fuse_t>(*fuse)};
|
||||
}
|
||||
return optional<enum_fuse_t>{};
|
||||
}
|
||||
|
|
@ -991,7 +991,7 @@ std::basic_ostream<Char, Traits>& operator<<(std::basic_ostream<Char, Traits>& o
|
|||
|
||||
template <typename Char, typename Traits, typename E, detail::enable_if_enum_t<E, int> = 0>
|
||||
std::basic_ostream<Char, Traits>& operator<<(std::basic_ostream<Char, Traits>& os, optional<E> value) {
|
||||
return value.has_value() ? (os << value.value()) : os;
|
||||
return value.has_value() ? (os << *value) : os;
|
||||
}
|
||||
|
||||
} // namespace magic_enum::ostream_operators
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue