From 29285919fdcaa9be4185112097cdf1265877a4f8 Mon Sep 17 00:00:00 2001 From: Bela Schaum Date: Fri, 18 Feb 2022 22:37:24 +0100 Subject: [PATCH] change std::size_t to std::uintmax_t (#141) --- include/magic_enum.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/magic_enum.hpp b/include/magic_enum.hpp index a2b28aa..eb8f68e 100644 --- a/include/magic_enum.hpp +++ b/include/magic_enum.hpp @@ -914,7 +914,7 @@ template > namespace fusion_detail { template -constexpr std::optional fuse_one_enum(std::optional hash, E value) noexcept { +constexpr std::optional fuse_one_enum(std::optional hash, E value) noexcept { if (hash.has_value()) { if (const auto index = enum_index(value); index.has_value()) { // Add 1 to prevent matching 2D fusions with 3D fusions etc. @@ -925,12 +925,12 @@ constexpr std::optional fuse_one_enum(std::optional ha } template -constexpr std::optional fuse_enum(E value) noexcept { +constexpr std::optional fuse_enum(E value) noexcept { return fuse_one_enum(0, value); } template -constexpr std::optional fuse_enum(E head, Es... tail) noexcept { +constexpr std::optional fuse_enum(E head, Es... tail) noexcept { return fuse_one_enum(fuse_enum(tail...), head); } @@ -938,9 +938,9 @@ constexpr std::optional fuse_enum(E head, Es... tail) noexcept { // Returns a bijective mix of several enum values. This can be used to emulate 2D switch/case statements. template -[[nodiscard]] constexpr auto enum_fuse(Es... values) -> std::enable_if_t<(std::is_enum_v> && ...), std::optional> { +[[nodiscard]] constexpr auto enum_fuse(Es... values) -> std::enable_if_t<(std::is_enum_v> && ...), std::optional> { static_assert(sizeof...(Es) >= 2, "magic_enum::enum_fuse requires at least 2 enums"); - static_assert((detail::log2(enum_count() + 1) + ...) <= (sizeof(std::size_t) * 8), "magic_enum::enum_fuse does not work for large enums"); + static_assert((detail::log2(enum_count() + 1) + ...) <= (sizeof(std::uintmax_t) * 8), "magic_enum::enum_fuse does not work for large enums"); const auto fuse = fusion_detail::fuse_enum(values...); return assert(fuse.has_value()), fuse; }