1
0
Fork 0
mirror of https://github.com/Neargye/magic_enum.git synced 2026-01-10 23:44:29 +00:00

remove std:: from optionals to enable again MAGIC_ENUM_USING_ALIAS_OPTIONAL (#154)

This commit is contained in:
Bela Schaum 2022-03-05 20:56:17 +01:00 committed by GitHub
parent ca89c5425b
commit 8267d2860b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -914,23 +914,23 @@ template <typename E, typename BinaryPredicate = std::equal_to<char>>
namespace fusion_detail { namespace fusion_detail {
template <typename E> template <typename E>
constexpr std::optional<std::uintmax_t> fuse_one_enum(std::optional<std::uintmax_t> hash, E value) noexcept { constexpr optional<std::uintmax_t> fuse_one_enum(optional<std::uintmax_t> hash, E value) noexcept {
if (hash.has_value()) { if (hash.has_value()) {
if (const auto index = enum_index(value); index.has_value()) { if (const auto index = enum_index(value); index.has_value()) {
// Add 1 to prevent matching 2D fusions with 3D fusions etc. // Add 1 to prevent matching 2D fusions with 3D fusions etc.
return (hash.value() << detail::log2(enum_count<E>() + 1)) | (index.value() + 1); return (hash.value() << detail::log2(enum_count<E>() + 1)) | (index.value() + 1);
} }
} }
return std::nullopt; return {};
} }
template <typename E> template <typename E>
constexpr std::optional<std::uintmax_t> fuse_enum(E value) noexcept { constexpr optional<std::uintmax_t> fuse_enum(E value) noexcept {
return fuse_one_enum(0, value); return fuse_one_enum(0, value);
} }
template <typename E, typename... Es> template <typename E, typename... Es>
constexpr std::optional<std::uintmax_t> fuse_enum(E head, Es... tail) noexcept { constexpr optional<std::uintmax_t> fuse_enum(E head, Es... tail) noexcept {
return fuse_one_enum(fuse_enum(tail...), head); return fuse_one_enum(fuse_enum(tail...), head);
} }