Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1491)

Unified Diff: Source/wtf/HashTable.h

Issue 23042005: [oilpan] Fix iterators over member collections to return Result<T> (Closed) Base URL: svn://svn.chromium.org/blink/branches/oilpan
Patch Set: Rebase Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/wtf/HashSet.h ('k') | Source/wtf/HashTraits.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/HashTable.h
diff --git a/Source/wtf/HashTable.h b/Source/wtf/HashTable.h
index 3a37c64dd9d3672f6cee626aef129ba13f314942..42e818ea27dde11d0fb275575b5dffa08ade3c8c 100644
--- a/Source/wtf/HashTable.h
+++ b/Source/wtf/HashTable.h
@@ -113,7 +113,7 @@ namespace WTF {
typedef HashTableIterator<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator> iterator;
typedef HashTableConstIterator<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator> const_iterator;
typedef Value ValueType;
- typedef const ValueType& ReferenceType;
+ typedef typename Traits::IteratorConstGetType GetType;
typedef const ValueType* PointerType;
typedef typename Allocator::template IteratorWitness<HashTableType>::Type IteratorWitnessType;
@@ -192,13 +192,13 @@ namespace WTF {
}
#endif
- PointerType get() const
+ GetType get() const
{
checkValidity();
return m_position;
}
- ReferenceType operator*() const { return *get(); }
- PointerType operator->() const { return get(); }
+ typename Traits::IteratorConstReferenceType operator*() const { return Traits::getToReferenceConstConversion(get()); }
+ GetType operator->() const { return get(); }
const_iterator& operator++()
{
@@ -274,7 +274,7 @@ namespace WTF {
typedef HashTableIterator<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator> iterator;
typedef HashTableConstIterator<Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator> const_iterator;
typedef Value ValueType;
- typedef ValueType& ReferenceType;
+ typedef typename Traits::IteratorGetType GetType;
typedef ValueType* PointerType;
typedef typename Allocator::template IteratorWitness<HashTableType>::Type IteratorWitnessType;
@@ -288,9 +288,9 @@ namespace WTF {
// default copy, assignment and destructor are OK
- PointerType get() const { return const_cast<PointerType>(m_iterator.get()); }
- ReferenceType operator*() const { return *get(); }
- PointerType operator->() const { return get(); }
+ GetType get() const { return const_cast<PointerType>(m_iterator.get()); }
+ typename Traits::IteratorReferenceType operator*() const { return Traits::getToReferenceConversion(get()); }
+ GetType operator->() const { return get(); }
iterator& operator++() { ++m_iterator; return *this; }
@@ -1430,13 +1430,15 @@ namespace WTF {
// iterator adapters
- template<typename HashTableType, typename ValueType> struct HashTableConstIteratorAdapter {
+ template<typename HashTableType, typename Traits> struct HashTableConstIteratorAdapter {
HashTableConstIteratorAdapter() {}
HashTableConstIteratorAdapter(const typename HashTableType::const_iterator& impl) : m_impl(impl) {}
+ typedef typename Traits::IteratorConstGetType GetType;
+ typedef typename HashTableType::ValueTraits::IteratorConstGetType SourceGetType;
- const ValueType* get() const { return (const ValueType*)m_impl.get(); }
- const ValueType& operator*() const { return *get(); }
- const ValueType* operator->() const { return get(); }
+ GetType get() const { return (GetType)SourceGetType(m_impl.get()); }
+ typename Traits::IteratorConstReferenceType operator*() const { return Traits::getToReferenceConstConversion(get()); }
+ GetType operator->() const { return get(); }
HashTableConstIteratorAdapter& operator++() { ++m_impl; return *this; }
// postfix ++ intentionally omitted
@@ -1444,18 +1446,22 @@ namespace WTF {
typename HashTableType::const_iterator m_impl;
};
- template<typename HashTableType, typename ValueType> struct HashTableIteratorAdapter {
+ template<typename HashTableType, typename Traits> struct HashTableIteratorAdapter {
+ typedef typename Traits::IteratorGetType GetType;
+ typedef typename HashTableType::ValueTraits::IteratorGetType SourceGetType;
+
HashTableIteratorAdapter() {}
HashTableIteratorAdapter(const typename HashTableType::iterator& impl) : m_impl(impl) {}
- ValueType* get() const { return (ValueType*)m_impl.get(); }
- ValueType& operator*() const { return *get(); }
- ValueType* operator->() const { return get(); }
+ GetType get() const { return (GetType)SourceGetType(m_impl.get()); }
+ typename Traits::IteratorReferenceType operator*() const { return Traits::getToReferenceConversion(get()); }
+ GetType operator->() const { return get(); }
HashTableIteratorAdapter& operator++() { ++m_impl; return *this; }
// postfix ++ intentionally omitted
- operator HashTableConstIteratorAdapter<HashTableType, ValueType>() {
+ operator HashTableConstIteratorAdapter<HashTableType, Traits>()
+ {
typename HashTableType::const_iterator i = m_impl;
return i;
}
« no previous file with comments | « Source/wtf/HashSet.h ('k') | Source/wtf/HashTraits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698