diff options
author | Michael Lutz <michi@icosahedron.de> | 2020-05-17 23:31:44 +0200 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2020-05-21 20:02:34 +0200 |
commit | f2b40f40aa7cbccaed20ec52b41d4704a45d8db1 (patch) | |
tree | 2f8268a7292118c9e460524a139ab85766ed3425 /src/core/smallmap_type.hpp | |
parent | 7309bdec48c70499301eb579991c2db6f7ef1d99 (diff) | |
download | openttd-f2b40f40aa7cbccaed20ec52b41d4704a45d8db1.tar.xz |
Codechange: Replace SmallPair with std::pair.
std::pair is already the smallest possible pair, and it already handles non-POD types correctly.
Diffstat (limited to 'src/core/smallmap_type.hpp')
-rw-r--r-- | src/core/smallmap_type.hpp | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/src/core/smallmap_type.hpp b/src/core/smallmap_type.hpp index 478e7515a..931a4848b 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 <utility> /** - * Simple pair of data. Both types have to be POD ("Plain Old Data")! - * @tparam T Key type. - * @tparam U Value type. - */ -template <typename T, typename U> -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 <typename T, typename U> -struct SmallMap : std::vector<SmallPair<T, U> > { - typedef ::SmallPair<T, U> Pair; +struct SmallMap : std::vector<std::pair<T, U> > { + typedef std::pair<T, U> 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() { } /** |