Skip to content

Commit ec09b2e

Browse files
committed
better support for random iterator
1 parent a2d7aa6 commit ec09b2e

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

include/boost/multi/array_ref.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -971,22 +971,20 @@ struct elements_iterator_t
971971
return *this;
972972
}
973973

974-
BOOST_MULTI_HD constexpr auto operator-(elements_iterator_t const& other) const -> difference_type {
974+
BOOST_MULTI_HD constexpr auto operator-(elements_iterator_t const& other) const noexcept -> difference_type {
975975
BOOST_MULTI_ASSERT(base_ == other.base_ && l_ == other.l_);
976976
return n_ - other.n_;
977977
}
978978

979-
// BOOST_MULTI_HD constexpr auto n() const { return n_; }
980-
981-
BOOST_MULTI_HD constexpr auto operator<(elements_iterator_t const& other) const -> bool {
979+
BOOST_MULTI_HD constexpr auto operator<(elements_iterator_t const& other) const noexcept -> bool {
982980
BOOST_MULTI_ASSERT(base_ == other.base_ && l_ == other.l_);
983981
return n_ < other.n_;
984982
}
985983

986-
BOOST_MULTI_HD constexpr auto operator<=(elements_iterator_t const& other) const -> bool { return ((*this) < other) || ((*this) == other); }
984+
BOOST_MULTI_HD constexpr auto operator<=(elements_iterator_t const& other) const noexcept -> bool { return ((*this) < other) || ((*this) == other); }
987985

988-
BOOST_MULTI_HD constexpr auto operator>(elements_iterator_t const& other) const -> bool { return other < (*this); }
989-
BOOST_MULTI_HD constexpr auto operator>=(elements_iterator_t const& other) const -> bool { return !((*this) < other); }
986+
BOOST_MULTI_HD constexpr auto operator>(elements_iterator_t const& other) const noexcept -> bool { return other < (*this); }
987+
BOOST_MULTI_HD constexpr auto operator>=(elements_iterator_t const& other) const noexcept -> bool { return !((*this) < other); }
990988

991989
#if defined(__clang__) && (__clang_major__ >= 16) && !defined(__INTEL_LLVM_COMPILER)
992990
#pragma clang diagnostic push
@@ -1016,9 +1014,11 @@ struct elements_iterator_t
10161014
ret += n;
10171015
return ret;
10181016
}
1017+
10191018
friend BOOST_MULTI_HD constexpr auto operator+(difference_type n, elements_iterator_t const& self) -> elements_iterator_t { // `n + it` form, required by std::random_access_iterator
10201019
return self + n;
10211020
}
1021+
10221022
BOOST_MULTI_HD constexpr auto operator-(difference_type n) const -> elements_iterator_t {
10231023
auto ret{*this};
10241024
ret -= n;

0 commit comments

Comments
 (0)