Skip to content

Commit b442b29

Browse files
mmatrosovMikhail Matrosov
and
Mikhail Matrosov
authored
Mark comparison operators as const (simdjson#1320)
Co-authored-by: Mikhail Matrosov <mikhail.matrosov@aimtech.com>
1 parent 5609851 commit b442b29

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

include/simdjson/generic/ondemand/array_iterator-inl.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ simdjson_really_inline simdjson_result<value> array_iterator<T>::operator*() noe
1919
return value::start(iter->borrow_iterator());
2020
}
2121
template<typename T>
22-
simdjson_really_inline bool array_iterator<T>::operator==(const array_iterator<T> &other) noexcept {
22+
simdjson_really_inline bool array_iterator<T>::operator==(const array_iterator<T> &other) const noexcept {
2323
return !(*this != other);
2424
}
2525
template<typename T>
26-
simdjson_really_inline bool array_iterator<T>::operator!=(const array_iterator<T> &) noexcept {
26+
simdjson_really_inline bool array_iterator<T>::operator!=(const array_iterator<T> &) const noexcept {
2727
return iter->is_iterator_alive();
2828
}
2929
template<typename T>
@@ -62,12 +62,12 @@ simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>
6262
return *this->first;
6363
}
6464
template<typename T>
65-
simdjson_really_inline bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>>::operator==(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>> &other) noexcept {
65+
simdjson_really_inline bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>>::operator==(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>> &other) const noexcept {
6666
if (this->error()) { return true; }
6767
return this->first == other.first;
6868
}
6969
template<typename T>
70-
simdjson_really_inline bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>>::operator!=(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>> &other) noexcept {
70+
simdjson_really_inline bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>>::operator!=(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>> &other) const noexcept {
7171
if (this->error()) { return false; }
7272
return this->first != other.first;
7373
}

include/simdjson/generic/ondemand/array_iterator.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ class array_iterator {
4141
*
4242
* @return true if there are no more elements in the JSON array.
4343
*/
44-
simdjson_really_inline bool operator==(const array_iterator<T> &) noexcept;
44+
simdjson_really_inline bool operator==(const array_iterator<T> &) const noexcept;
4545
/**
4646
* Check if there are more elements in the JSON array.
4747
*
4848
* Part of the std::iterator interface.
4949
*
5050
* @return true if there are more elements in the JSON array.
5151
*/
52-
simdjson_really_inline bool operator!=(const array_iterator<T> &) noexcept;
52+
simdjson_really_inline bool operator!=(const array_iterator<T> &) const noexcept;
5353
/**
5454
* Move to the next element.
5555
*
@@ -91,8 +91,8 @@ struct simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>> : p
9191
//
9292

9393
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> operator*() noexcept; // MUST ONLY BE CALLED ONCE PER ITERATION.
94-
simdjson_really_inline bool operator==(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>> &) noexcept;
95-
simdjson_really_inline bool operator!=(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>> &) noexcept;
94+
simdjson_really_inline bool operator==(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>> &) const noexcept;
95+
simdjson_really_inline bool operator!=(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>> &) const noexcept;
9696
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator<T>> &operator++() noexcept;
9797
};
9898

include/simdjson/generic/ondemand/object_iterator-inl.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ simdjson_really_inline simdjson_result<field> object_iterator::operator*() noexc
1717
if (result.error()) { iter->release(); }
1818
return result;
1919
}
20-
simdjson_really_inline bool object_iterator::operator==(const object_iterator &other) noexcept {
20+
simdjson_really_inline bool object_iterator::operator==(const object_iterator &other) const noexcept {
2121
return !(*this != other);
2222
}
23-
simdjson_really_inline bool object_iterator::operator!=(const object_iterator &) noexcept {
23+
simdjson_really_inline bool object_iterator::operator!=(const object_iterator &) const noexcept {
2424
return iter->is_alive();
2525
}
2626
simdjson_really_inline object_iterator &object_iterator::operator++() noexcept {
@@ -55,12 +55,12 @@ simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::field>
5555
return *first;
5656
}
5757
// Assumes it's being compared with the end. true if depth < iter->depth.
58-
simdjson_really_inline bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator>::operator==(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &other) noexcept {
58+
simdjson_really_inline bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator>::operator==(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &other) const noexcept {
5959
if (error()) { return true; }
6060
return first == other.first;
6161
}
6262
// Assumes it's being compared with the end. true if depth >= iter->depth.
63-
simdjson_really_inline bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator>::operator!=(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &other) noexcept {
63+
simdjson_really_inline bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator>::operator!=(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &other) const noexcept {
6464
if (error()) { return false; }
6565
return first != other.first;
6666
}

include/simdjson/generic/ondemand/object_iterator.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ class object_iterator {
2626
// MUST ONLY BE CALLED ONCE PER ITERATION.
2727
simdjson_really_inline simdjson_result<field> operator*() noexcept;
2828
// Assumes it's being compared with the end. true if depth < iter->depth.
29-
simdjson_really_inline bool operator==(const object_iterator &) noexcept;
29+
simdjson_really_inline bool operator==(const object_iterator &) const noexcept;
3030
// Assumes it's being compared with the end. true if depth >= iter->depth.
31-
simdjson_really_inline bool operator!=(const object_iterator &) noexcept;
31+
simdjson_really_inline bool operator!=(const object_iterator &) const noexcept;
3232
// Checks for ']' and ','
3333
simdjson_really_inline object_iterator &operator++() noexcept;
3434
private:
@@ -61,9 +61,9 @@ struct simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> : pub
6161
// Reads key and value, yielding them to the user.
6262
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::field> operator*() noexcept; // MUST ONLY BE CALLED ONCE PER ITERATION.
6363
// Assumes it's being compared with the end. true if depth < iter->depth.
64-
simdjson_really_inline bool operator==(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &) noexcept;
64+
simdjson_really_inline bool operator==(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &) const noexcept;
6565
// Assumes it's being compared with the end. true if depth >= iter->depth.
66-
simdjson_really_inline bool operator!=(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &) noexcept;
66+
simdjson_really_inline bool operator!=(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &) const noexcept;
6767
// Checks for ']' and ','
6868
simdjson_really_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &operator++() noexcept;
6969
};

0 commit comments

Comments
 (0)