diff --git a/src/core/smallmap_type.hpp b/src/core/smallmap_type.hpp index 478e7515a6..931a4848b3 100644 --- a/src/core/smallmap_type.hpp +++ b/src/core/smallmap_type.hpp @@ -11,40 +11,26 @@ #define SMALLMAP_TYPE_HPP #include "smallvec_type.hpp" +#include /** - * Simple pair of data. Both types have to be POD ("Plain Old Data")! - * @tparam T Key type. - * @tparam U Value type. - */ -template -struct SmallPair { - T first; - U second; - - /** Initializes this Pair with data */ - inline SmallPair(const T &first, const U &second) : first(first), second(second) { } - SmallPair() = default; -}; - -/** - * Implementation of simple mapping class. Both types have to be POD ("Plain Old Data")! - * It has inherited accessors from SmallVector(). + * Implementation of simple mapping class. + * It has inherited accessors from std::vector(). * @tparam T Key type. * @tparam U Value type. * @tparam S Unit of allocation. * - * @see SmallVector + * @see std::vector */ template -struct SmallMap : std::vector > { - typedef ::SmallPair Pair; +struct SmallMap : std::vector > { + typedef std::pair Pair; typedef Pair *iterator; typedef const Pair *const_iterator; - /** Creates new SmallMap. Data are initialized in SmallVector constructor */ + /** Creates new SmallMap. Data are initialized in std::vector constructor */ inline SmallMap() { } - /** Data are freed in SmallVector destructor */ + /** Data are freed in std::vector destructor */ inline ~SmallMap() { } /** diff --git a/src/fontcache.cpp b/src/fontcache.cpp index 9102f356ad..6cdac1fab8 100644 --- a/src/fontcache.cpp +++ b/src/fontcache.cpp @@ -211,7 +211,7 @@ protected: int req_size; ///< Requested font size. int used_size; ///< Used font size. - typedef SmallMap > FontTable; ///< Table with font table cache + typedef SmallMap > FontTable; ///< Table with font table cache FontTable font_tables; ///< Cached font tables. /** Container for information about a glyph. */ @@ -434,7 +434,7 @@ const void *TrueTypeFontCache::GetFontTable(uint32 tag, size_t &length) const void *result = this->InternalGetFontTable(tag, length); - this->font_tables.Insert(tag, SmallPair(length, result)); + this->font_tables.Insert(tag, std::pair(length, result)); return result; } diff --git a/src/linkgraph/linkgraph.h b/src/linkgraph/linkgraph.h index 997d946230..7362b7d568 100644 --- a/src/linkgraph/linkgraph.h +++ b/src/linkgraph/linkgraph.h @@ -17,6 +17,7 @@ #include "../cargotype.h" #include "../date_func.h" #include "linkgraph_type.h" +#include struct SaveLoad; class LinkGraph; @@ -188,20 +189,20 @@ public: * to return something that implements operator->, but isn't a pointer * from operator->. A fake pointer. */ - class FakePointer : public SmallPair { + class FakePointer : public std::pair { public: /** * Construct a fake pointer from a pair of NodeID and edge. * @param pair Pair to be "pointed" to (in fact shallow-copied). */ - FakePointer(const SmallPair &pair) : SmallPair(pair) {} + FakePointer(const std::pair &pair) : std::pair(pair) {} /** * Retrieve the pair by operator->. * @return Pair being "pointed" to. */ - SmallPair *operator->() { return this; } + std::pair *operator->() { return this; } }; public: @@ -266,9 +267,9 @@ public: * Dereference with operator*. * @return Pair of current target NodeID and edge object. */ - SmallPair operator*() const + std::pair operator*() const { - return SmallPair(this->current, Tedge_wrapper(this->base[this->current])); + return std::pair(this->current, Tedge_wrapper(this->base[this->current])); } /** diff --git a/src/linkgraph/linkgraphjob.h b/src/linkgraph/linkgraphjob.h index 9344ea2462..cd7ece4b1e 100644 --- a/src/linkgraph/linkgraphjob.h +++ b/src/linkgraph/linkgraphjob.h @@ -160,9 +160,9 @@ public: * @return Pair of the edge currently pointed to and the ID of its * other end. */ - SmallPair operator*() const + std::pair operator*() const { - return SmallPair(this->current, Edge(this->base[this->current], this->base_anno[this->current])); + return std::pair(this->current, Edge(this->base[this->current], this->base_anno[this->current])); } /** diff --git a/src/newgrf.cpp b/src/newgrf.cpp index c422fe99c0..c1b8364811 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -8113,7 +8113,7 @@ static bool ChangeGRFParamValueNames(ByteReader *buf) byte langid = buf->ReadByte(); const char *name_string = buf->ReadString(); - SmallPair *val_name = _cur_parameter->value_names.Find(id); + std::pair *val_name = _cur_parameter->value_names.Find(id); if (val_name != _cur_parameter->value_names.End()) { AddGRFTextToList(&val_name->second, langid, _cur.grfconfig->ident.grfid, false, name_string); } else { diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp index a0960350da..605bceca5b 100644 --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -262,7 +262,7 @@ GRFParameterInfo::GRFParameterInfo(GRFParameterInfo &info) : complete_labels(info.complete_labels) { for (uint i = 0; i < info.value_names.size(); i++) { - SmallPair *data = info.value_names.data() + i; + std::pair *data = info.value_names.data() + i; this->value_names.Insert(data->first, DuplicateGRFText(data->second)); } } @@ -273,7 +273,7 @@ GRFParameterInfo::~GRFParameterInfo() CleanUpGRFText(this->name); CleanUpGRFText(this->desc); for (uint i = 0; i < this->value_names.size(); i++) { - SmallPair *data = this->value_names.data() + i; + std::pair *data = this->value_names.data() + i; CleanUpGRFText(data->second); } } diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index a8ba3d5260..19757646d7 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -804,7 +804,7 @@ GrfSpecFeature GetGrfSpecFeature(VehicleType type) /** Window used for aligning sprites. */ struct SpriteAlignerWindow : Window { - typedef SmallPair XyOffs; ///< Pair for x and y offsets of the sprite before alignment. First value contains the x offset, second value y offset. + typedef std::pair XyOffs; ///< Pair for x and y offsets of the sprite before alignment. First value contains the x offset, second value y offset. SpriteID current_sprite; ///< The currently shown sprite. Scrollbar *vscroll; diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp index c08877198d..1345119446 100644 --- a/src/newgrf_text.cpp +++ b/src/newgrf_text.cpp @@ -196,7 +196,7 @@ struct UnmappedChoiceList : ZeroedMemoryAllocator { /** Clean everything up. */ ~UnmappedChoiceList() { - for (SmallPair p : this->strings) { + for (std::pair p : this->strings) { free(p.second); } } diff --git a/src/vehicle.cpp b/src/vehicle.cpp index ae5af64a1a..72ef5a31ad 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -2278,7 +2278,7 @@ void Vehicle::GetConsistFreeCapacities(SmallMap &capacities) cons { for (const Vehicle *v = this; v != nullptr; v = v->Next()) { if (v->cargo_cap == 0) continue; - SmallPair *pair = capacities.Find(v->cargo_type); + std::pair *pair = capacities.Find(v->cargo_type); if (pair == capacities.End()) { capacities.push_back({v->cargo_type, v->cargo_cap - v->cargo.StoredCount()}); } else {