Remove EndSentinel, not allowed in C++14.

This commit is contained in:
levlam 2022-03-13 23:14:18 +03:00
parent daef14ade1
commit 057b2d1e05

View File

@ -45,7 +45,8 @@ class FlatHashTable {
using key_type = typename NodeT::public_key_type;
using value_type = typename NodeT::public_type;
struct EndSentinel {};
// TODO use EndSentinel for end() after switching to C++17
// struct EndSentinel {};
struct Iterator {
using iterator_category = std::forward_iterator_tag;
@ -84,10 +85,12 @@ class FlatHashTable {
return it_;
}
bool operator==(const EndSentinel &other) const {
bool operator==(const Iterator &other) const {
DCHECK(other.it_ == nullptr);
return it_ == nullptr;
}
bool operator!=(const EndSentinel &other) const {
bool operator!=(const Iterator &other) const {
DCHECK(other.it_ == nullptr);
return it_ != nullptr;
}
@ -119,11 +122,11 @@ class FlatHashTable {
pointer operator->() const {
return &*it_;
}
bool operator==(const EndSentinel &other) const {
return it_ == other;
bool operator==(const ConstIterator &other) const {
return it_ == other.it_;
}
bool operator!=(const EndSentinel &other) const {
return it_ != other;
bool operator!=(const ConstIterator &other) const {
return it_ != other.it_;
}
ConstIterator() = default;
@ -154,10 +157,10 @@ class FlatHashTable {
return it_;
}
bool operator==(const EndSentinel &other) const {
bool operator==(const Iterator &) const {
return it_ == nullptr;
}
bool operator!=(const EndSentinel &other) const {
bool operator!=(const Iterator &) const {
return it_ != nullptr;
}
@ -176,10 +179,10 @@ class FlatHashTable {
return &it_->get_public();
}
bool operator==(const EndSentinel &other) const {
bool operator==(const ConstIterator &) const {
return it_ == nullptr;
}
bool operator!=(const EndSentinel &other) const {
bool operator!=(const ConstIterator &) const {
return it_ != nullptr;
}
@ -282,12 +285,14 @@ class FlatHashTable {
Iterator begin() {
return create_iterator(begin_impl());
}
Iterator end() {
return Iterator();
}
ConstIterator begin() const {
return ConstIterator(const_cast<FlatHashTable *>(this)->begin());
}
EndSentinel end() const {
return EndSentinel();
ConstIterator end() const {
return ConstIterator();
}
void reserve(size_t size) {