(svn r17810) -Codechange/Fix: Add assert_tcompile() and use it.

OTTD's traditional assert_compile() does not work inside templates for gcc compilers, static_assert() does though.
  The new assert_tcompile() resolves into static_assert() if present, or into a runtime assert() else.
This commit is contained in:
frosch
2009-10-18 20:26:29 +00:00
parent fea06c5755
commit b8f8c60839
2 changed files with 4 additions and 1 deletions

View File

@@ -85,7 +85,7 @@ static void GetCargoSuffix(uint cargo, CargoSuffixType cst, const Industry *ind,
template <typename TC, typename TS>
static inline void GetAllCargoSuffixes(uint cb_offset, CargoSuffixType cst, const Industry *ind, IndustryType ind_type, const IndustrySpec *indspec, const TC &cargos, TS &suffixes)
{
assert_compile(lengthof(cargos) <= lengthof(suffixes));
assert_tcompile(lengthof(cargos) <= lengthof(suffixes));
for (uint j = 0; j < lengthof(cargos); j++) {
if (cargos[j] != CT_INVALID) {
GetCargoSuffix(cb_offset + j, cst, ind, ind_type, indspec, suffixes[j], lastof(suffixes[j]));