mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: replace cpp_lengthof with safe alternatives
This commit is contained in:
parent
a1a01e21cf
commit
c377c4740d
|
@ -2380,8 +2380,8 @@ private:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(MAX_CARGOES >= cpp_lengthof(IndustrySpec, produced_cargo));
|
static_assert(MAX_CARGOES >= std::tuple_size_v<decltype(IndustrySpec::produced_cargo)>);
|
||||||
static_assert(MAX_CARGOES >= cpp_lengthof(IndustrySpec, accepts_cargo));
|
static_assert(MAX_CARGOES >= std::tuple_size_v<decltype(IndustrySpec::accepts_cargo)>);
|
||||||
|
|
||||||
Dimension CargoesField::legend; ///< Dimension of the legend blob.
|
Dimension CargoesField::legend; ///< Dimension of the legend blob.
|
||||||
Dimension CargoesField::cargo_border; ///< Dimensions of border between cargo lines and industry boxes.
|
Dimension CargoesField::cargo_border; ///< Dimensions of border between cargo lines and industry boxes.
|
||||||
|
|
|
@ -206,6 +206,6 @@ struct PersistentStorage : PersistentStorageArray<int32_t, 256>, PersistentStora
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(cpp_lengthof(OldPersistentStorage, storage) <= cpp_lengthof(PersistentStorage, storage));
|
static_assert(std::tuple_size_v<decltype(OldPersistentStorage::storage)> <= std::tuple_size_v<decltype(PersistentStorage::storage)>);
|
||||||
|
|
||||||
#endif /* NEWGRF_STORAGE_H */
|
#endif /* NEWGRF_STORAGE_H */
|
||||||
|
|
|
@ -301,14 +301,6 @@ char (&ArraySizeHelper(T (&array)[N]))[N];
|
||||||
*/
|
*/
|
||||||
#define cpp_sizeof(base, variable) (sizeof(std::declval<base>().variable))
|
#define cpp_sizeof(base, variable) (sizeof(std::declval<base>().variable))
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the length of an array variable within a class.
|
|
||||||
* @param base The class the variable is in.
|
|
||||||
* @param variable The array variable to get the size of.
|
|
||||||
* @return the length of the array
|
|
||||||
*/
|
|
||||||
#define cpp_lengthof(base, variable) (cpp_sizeof(base, variable) / cpp_sizeof(base, variable[0]))
|
|
||||||
|
|
||||||
|
|
||||||
/* take care of some name clashes on MacOS */
|
/* take care of some name clashes on MacOS */
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
|
|
Loading…
Reference in New Issue