diff --git a/src/bridge.h b/src/bridge.h index 0d64dd6012e31..da5a373a0785a 100644 --- a/src/bridge.h +++ b/src/bridge.h @@ -65,7 +65,7 @@ bool HasBridgeFlatRamp(Slope tileh, Axis axis); */ inline const BridgeSpec *GetBridgeSpec(BridgeType i) { - assert(i < lengthof(_bridge)); + assert(i < std::size(_bridge)); return &_bridge[i]; } diff --git a/src/cargotype.h b/src/cargotype.h index 10aae014d2aa6..4a7485453e585 100644 --- a/src/cargotype.h +++ b/src/cargotype.h @@ -120,7 +120,7 @@ struct CargoSpec { */ static inline size_t GetArraySize() { - return lengthof(CargoSpec::array); + return std::size(CargoSpec::array); } /** @@ -130,7 +130,7 @@ struct CargoSpec { */ static inline CargoSpec *Get(size_t index) { - assert(index < lengthof(CargoSpec::array)); + assert(index < CargoSpec::GetArraySize()); return &CargoSpec::array[index]; } diff --git a/src/company_manager_face.h b/src/company_manager_face.h index dbb11de5fd9ea..61278305200f3 100644 --- a/src/company_manager_face.h +++ b/src/company_manager_face.h @@ -83,7 +83,7 @@ static const CompanyManagerFaceBitsInfo _cmf_info[] = { /* CMFV_GLASSES */ { 31, 1, { 2, 2, 2, 2 }, { 0x347, 0x347, 0x3AE, 0x3AE } } ///< Depends on CMFV_HAS_GLASSES }; /** Make sure the table's size is right. */ -static_assert(lengthof(_cmf_info) == CMFV_END); +static_assert(std::size(_cmf_info) == CMFV_END); /** * Gets the company manager's face bits for the given company manager's face variable diff --git a/src/table/airport_defaults.h b/src/table/airport_defaults.h index 0a41f7ec8ca86..5927e6d8c32b4 100644 --- a/src/table/airport_defaults.h +++ b/src/table/airport_defaults.h @@ -404,7 +404,7 @@ extern const AirportSpec _origin_airport_specs[] = { AS_GENERIC(&_airportfta_oilrig, {}, {}, 1, 1, 0, 4, 0, 0, 0, ATP_TTDP_OILRIG, APC_HELIPORT, STR_NULL, 0, false), }; -static_assert(NEW_AIRPORT_OFFSET == lengthof(_origin_airport_specs)); +static_assert(NEW_AIRPORT_OFFSET == std::size(_origin_airport_specs)); const AirportSpec AirportSpec::dummy = AS_GENERIC(&_airportfta_dummy, {}, {}, 0, 0, 0, 0, CalendarTime::MIN_YEAR, CalendarTime::MIN_YEAR, 0, ATP_TTDP_LARGE, APC_BEGIN, STR_NULL, 0, false); diff --git a/src/table/airporttiles.h b/src/table/airporttiles.h index 0393cf7a5f472..6f18f0e8a46d9 100644 --- a/src/table/airporttiles.h +++ b/src/table/airporttiles.h @@ -104,7 +104,7 @@ static const AirportTileSpec _origin_airporttile_specs[] = { AT(3, 1), // APT_GRASS_FENCE_NE_FLAG_2 }; -static_assert(NEW_AIRPORTTILE_OFFSET == lengthof(_origin_airporttile_specs)); +static_assert(NEW_AIRPORTTILE_OFFSET == std::size(_origin_airporttile_specs)); #undef AT_NOANIM #undef AT diff --git a/src/table/newgrf_debug_data.h b/src/table/newgrf_debug_data.h index 1be431a939132..26fec23d7e4db 100644 --- a/src/table/newgrf_debug_data.h +++ b/src/table/newgrf_debug_data.h @@ -743,4 +743,4 @@ static const NIFeature * const _nifeatures[] = { &_nif_roadstop, // GSF_ROADSTOPS &_nif_town, // GSF_FAKE_TOWNS }; -static_assert(lengthof(_nifeatures) == GSF_FAKE_END); +static_assert(std::size(_nifeatures) == GSF_FAKE_END); diff --git a/src/table/pricebase.h b/src/table/pricebase.h index 27af6a370ed26..5e6599d438606 100644 --- a/src/table/pricebase.h +++ b/src/table/pricebase.h @@ -80,4 +80,4 @@ extern const PriceBaseSpec _price_base_specs[] = { { 100, PCAT_RUNNING, GSF_END, PR_STATION_VALUE }, ///< PR_INFRASTRUCTURE_STATION { 5000, PCAT_RUNNING, GSF_END, PR_BUILD_STATION_AIRPORT}, ///< PR_INFRASTRUCTURE_AIRPORT }; -static_assert(lengthof(_price_base_specs) == PR_END); +static_assert(std::size(_price_base_specs) == PR_END); diff --git a/src/table/station_land.h b/src/table/station_land.h index fc47de8d77810..1053cca21a2a2 100644 --- a/src/table/station_land.h +++ b/src/table/station_land.h @@ -1011,7 +1011,7 @@ static const DrawTileSprites _station_display_datas_waypoint[] = { /* Default waypoint is also drawn as fallback for NewGRF waypoints. * As these are drawn/build like stations, they may use the same number of layouts. */ -static_assert(lengthof(_station_display_datas_rail) == lengthof(_station_display_datas_waypoint)); +static_assert(std::size(_station_display_datas_rail) == std::size(_station_display_datas_waypoint)); static const DrawTileSprites * const _station_display_datas[] = { _station_display_datas_rail, diff --git a/src/table/town_land.h b/src/table/town_land.h index 586a94b3a8fe0..92d09cb770741 100644 --- a/src/table/town_land.h +++ b/src/table/town_land.h @@ -1788,7 +1788,7 @@ static const DrawBuildingsTileStruct _town_draw_tile_data[] = { }; #undef M /** Make sure we have the right number of elements: 4 variants * 4 build stages for each house */ -static_assert(lengthof(_town_draw_tile_data) == (NEW_HOUSE_OFFSET) * 4 * 4); +static_assert(std::size(_town_draw_tile_data) == (NEW_HOUSE_OFFSET) * 4 * 4); /** * Describes the data that defines each house in the game @@ -2277,4 +2277,4 @@ extern const HouseSpec _original_house_specs[] = { #undef MS /** Make sure we have the right number of elements: one entry for each house */ -static_assert(lengthof(_original_house_specs) == NEW_HOUSE_OFFSET); +static_assert(std::size(_original_house_specs) == NEW_HOUSE_OFFSET); diff --git a/src/table/train_sprites.h b/src/table/train_sprites.h index 36dfba17859fb..e4e2b32b75a28 100644 --- a/src/table/train_sprites.h +++ b/src/table/train_sprites.h @@ -63,6 +63,6 @@ static const uint8_t _wagon_full_adder[] = { 32, 32 }; -static_assert(lengthof(_engine_sprite_base) == lengthof(_engine_sprite_and)); -static_assert(lengthof(_engine_sprite_base) == lengthof(_engine_sprite_add)); -static_assert(lengthof(_engine_sprite_base) == lengthof(_wagon_full_adder)); +static_assert(std::size(_engine_sprite_base) == std::size(_engine_sprite_and)); +static_assert(std::size(_engine_sprite_base) == std::size(_engine_sprite_add)); +static_assert(std::size(_engine_sprite_base) == std::size(_wagon_full_adder));