From ee7259e48bb33fd291fd972950ce7e9294d3e463 Mon Sep 17 00:00:00 2001 From: FauziAkram Date: Thu, 13 Feb 2025 23:09:30 +0300 Subject: [PATCH] Small code cleanup Use std::is_arithmetic_v as it is the more modern and concise way to check for arithmetic types. While at it, fixing a static assert in misc.h, thanks to Shawn and Disservin for helping. closes https://github.com/official-stockfish/Stockfish/pull/5883 No functional change --- src/history.h | 2 +- src/misc.h | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/history.h b/src/history.h index 9ae7bdad..fd9b98b9 100644 --- a/src/history.h +++ b/src/history.h @@ -71,7 +71,7 @@ inline int non_pawn_index(const Position& pos) { template class StatsEntry { - static_assert(std::is_arithmetic::value, "Not an arithmetic type"); + static_assert(std::is_arithmetic_v, "Not an arithmetic type"); static_assert(D <= std::numeric_limits::max(), "D overflows T"); T entry; diff --git a/src/misc.h b/src/misc.h index 8adbac68..d2cbb699 100644 --- a/src/misc.h +++ b/src/misc.h @@ -155,6 +155,10 @@ struct MultiArrayHelper { using ChildType = T; }; +template +constexpr bool is_strictly_assignable_v = + std::is_assignable_v && (std::is_same_v || !std::is_convertible_v); + } // MultiArray is a generic N-dimensional array. @@ -212,7 +216,8 @@ class MultiArray { template void fill(const U& v) { - static_assert(std::is_assignable_v, "Cannot assign fill value to entry type"); + static_assert(Detail::is_strictly_assignable_v, + "Cannot assign fill value to entry type"); for (auto& ele : data_) { if constexpr (sizeof...(Sizes) == 0)