mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:07:36 +00:00
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.
This commit is contained in:
parent
9a7dc06567
commit
d5bb98acbc
14 changed files with 61 additions and 31 deletions
10
AK/Vector.h
10
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue