summaryrefslogtreecommitdiff
path: root/AK/Vector.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-06-29 19:14:03 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-06-29 19:14:03 +0200
commitd5bb98acbcdbd39fcc8d028517189f44bc78e710 (patch)
treec8392686c2e277aac417df1627d4a09bff319838 /AK/Vector.h
parent9a7dc065676c5d60707c263f7c6b0f97fba38ad6 (diff)
downloadserenity-d5bb98acbcdbd39fcc8d028517189f44bc78e710.zip
AK: Defer to Traits<T> for equality comparison in container templates.
This is prep work for supporting HashMap with NonnullRefPtr<T> as values. It's currently not possible because many HashTable functions require being able to default-construct the value type.
Diffstat (limited to 'AK/Vector.h')
-rw-r--r--AK/Vector.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/AK/Vector.h b/AK/Vector.h
index 1ae11d6cab..176b05d9ff 100644
--- a/AK/Vector.h
+++ b/AK/Vector.h
@@ -2,22 +2,24 @@
#include <AK/Assertions.h>
#include <AK/StdLibExtras.h>
+#include <AK/Traits.h>
#include <AK/kmalloc.h>
// NOTE: We can't include <initializer_list> during the toolchain bootstrap,
// since it's part of libstdc++, and libstdc++ depends on LibC.
// For this reason, we don't support Vector(initializer_list) in LibC.
#ifndef SERENITY_LIBC_BUILD
-#include <initializer_list>
+# include <initializer_list>
#endif
#ifndef __serenity__
-#include <new>
+# include <new>
#endif
namespace AK {
-template<typename T, int inline_capacity> class Vector;
+template<typename T, int inline_capacity>
+class Vector;
template<typename VectorType, typename ElementType>
class VectorIterator {
@@ -148,7 +150,7 @@ public:
bool contains_slow(const T& value) const
{
for (int i = 0; i < size(); ++i) {
- if (at(i) == value)
+ if (Traits<T>::equals(at(i), value))
return true;
}
return false;