summaryrefslogtreecommitdiff
path: root/src/core/smallvec_type.hpp
diff options
context:
space:
mode:
authorHenry Wilson <m3henry@googlemail.com>2018-09-23 22:15:35 +0100
committerPeterN <peter@fuzzle.org>2019-03-26 20:15:57 +0000
commit846095224044b39ddd3249b6ea072e486ba1fe38 (patch)
treeae8a22887b9b5f8fc8b4a7695826af739c3cc2de /src/core/smallvec_type.hpp
parent81315939b909a95277ffbab51709714779089656 (diff)
downloadopenttd-846095224044b39ddd3249b6ea072e486ba1fe38.tar.xz
Codechange: Replaced SmallVector::Find() const with suitable alternatives
The use of std::none_of in network/core/host.cpp is driven by the non-const comparison operator use by NetworkAddress. A future commit should address the const_casts in that class to ensure const-correctness.
Diffstat (limited to 'src/core/smallvec_type.hpp')
-rw-r--r--src/core/smallvec_type.hpp20
1 files changed, 3 insertions, 17 deletions
diff --git a/src/core/smallvec_type.hpp b/src/core/smallvec_type.hpp
index 289cc9e1d..1c713470f 100644
--- a/src/core/smallvec_type.hpp
+++ b/src/core/smallvec_type.hpp
@@ -106,26 +106,12 @@ public:
* Search for the first occurrence of an item.
* The '!=' operator of T is used for comparison.
* @param item Item to search for
- * @return The position of the item, or End() when not present
- */
- inline const T *Find(const T &item) const
- {
- const T *pos = this->Begin();
- const T *end = this->End();
- while (pos != end && *pos != item) pos++;
- return pos;
- }
-
- /**
- * Search for the first occurrence of an item.
- * The '!=' operator of T is used for comparison.
- * @param item Item to search for
* @return The position of the item, or -1 when not present
*/
inline int FindIndex(const T &item) const
{
- auto const it = this->Find(item);
- return it == this->End() ? -1 : it - this->Begin();
+ auto const it = std::find(std::vector<T>::begin(), std::vector<T>::end(), item);
+ return it == std::vector<T>::end() ? -1 : it - std::vector<T>::begin();
}
/**
@@ -136,7 +122,7 @@ public:
*/
inline bool Contains(const T &item) const
{
- return this->Find(item) != this->End();
+ return std::find(std::vector<T>::begin(), std::vector<T>::end(), item) != std::vector<T>::end();
}
/**