Просмотр исходного кода

bit: refine fast_mod implementation

skypjack 2 месяцев назад
Родитель
Сommit
23dc5eb501
1 измененных файлов с 3 добавлено и 4 удалено
  1. 3 4
      src/entt/core/bit.hpp

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

@@ -2,9 +2,8 @@
 #define ENTT_CORE_BIT_HPP
 #define ENTT_CORE_BIT_HPP
 
 
 #include <bit>
 #include <bit>
+#include <concepts>
 #include <cstddef>
 #include <cstddef>
-#include <limits>
-#include <type_traits>
 #include "../config/config.h"
 #include "../config/config.h"
 
 
 namespace entt {
 namespace entt {
@@ -16,8 +15,8 @@ namespace entt {
  * @param mod _Modulus_, it must be a power of two.
  * @param mod _Modulus_, it must be a power of two.
  * @return The common remainder.
  * @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");
     ENTT_ASSERT_CONSTEXPR(std::has_single_bit(mod), "Value must be a power of two");
     return static_cast<Type>(value & (mod - 1u));
     return static_cast<Type>(value & (mod - 1u));
 }
 }