Codechange: Replace SmallPair with std::pair.

std::pair is already the smallest possible pair, and it already handles non-POD types correctly.
This commit is contained in:
Michael Lutz
2020-05-17 23:31:44 +02:00
parent 7309bdec48
commit f2b40f40aa
9 changed files with 24 additions and 37 deletions

View File

@@ -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() { }
/**