mirror of
https://github.com/official-stockfish/Stockfish.git
synced 2026-07-22 20:57:10 +00:00
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
This commit is contained in:
+1
-1
@@ -71,7 +71,7 @@ inline int non_pawn_index(const Position& pos) {
|
|||||||
template<typename T, int D>
|
template<typename T, int D>
|
||||||
class StatsEntry {
|
class StatsEntry {
|
||||||
|
|
||||||
static_assert(std::is_arithmetic<T>::value, "Not an arithmetic type");
|
static_assert(std::is_arithmetic_v<T>, "Not an arithmetic type");
|
||||||
static_assert(D <= std::numeric_limits<T>::max(), "D overflows T");
|
static_assert(D <= std::numeric_limits<T>::max(), "D overflows T");
|
||||||
|
|
||||||
T entry;
|
T entry;
|
||||||
|
|||||||
+6
-1
@@ -155,6 +155,10 @@ struct MultiArrayHelper<T, Size> {
|
|||||||
using ChildType = T;
|
using ChildType = T;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename To, typename From>
|
||||||
|
constexpr bool is_strictly_assignable_v =
|
||||||
|
std::is_assignable_v<To&, From> && (std::is_same_v<To, From> || !std::is_convertible_v<From, To>);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MultiArray is a generic N-dimensional array.
|
// MultiArray is a generic N-dimensional array.
|
||||||
@@ -212,7 +216,8 @@ class MultiArray {
|
|||||||
|
|
||||||
template<typename U>
|
template<typename U>
|
||||||
void fill(const U& v) {
|
void fill(const U& v) {
|
||||||
static_assert(std::is_assignable_v<T, U>, "Cannot assign fill value to entry type");
|
static_assert(Detail::is_strictly_assignable_v<T, U>,
|
||||||
|
"Cannot assign fill value to entry type");
|
||||||
for (auto& ele : data_)
|
for (auto& ele : data_)
|
||||||
{
|
{
|
||||||
if constexpr (sizeof...(Sizes) == 0)
|
if constexpr (sizeof...(Sizes) == 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user