Răsfoiți Sursa

bit: refine fast_mod implementation

skypjack 1 lună în urmă
părinte
comite
23dc5eb501
1 a modificat fișierele cu 3 adăugiri și 4 ștergeri
  1. 3 4
      src/entt/core/bit.hpp

+ 3 - 4
src/entt/core/bit.hpp

@@ -2,9 +2,8 @@
 #define ENTT_CORE_BIT_HPP
 
 #include <bit>
+#include <concepts>
 #include <cstddef>
-#include <limits>
-#include <type_traits>
 #include "../config/config.h"
 
 namespace entt {
@@ -16,8 +15,8 @@ namespace entt {
  * @param mod _Modulus_, it must be a power of two.
  * @return The common remainder.
  */
-template<typename Type>
-[[nodiscard]] constexpr std::enable_if_t<std::is_unsigned_v<Type>, Type> fast_mod(const Type value, const std::size_t mod) noexcept {
+template<std::unsigned_integral Type>
+[[nodiscard]] constexpr Type fast_mod(const Type value, const std::size_t mod) noexcept {
     ENTT_ASSERT_CONSTEXPR(std::has_single_bit(mod), "Value must be a power of two");
     return static_cast<Type>(value & (mod - 1u));
 }