Merge pull request #616 from neilmacintosh/tidy-comparison-ops

Tidy up span comparison ops
This commit is contained in:
Anna Gringauze 2018-02-11 22:36:32 -08:00 committed by GitHub
commit 3a12c55cb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -199,7 +199,7 @@ namespace details
constexpr span_iterator& operator-=(difference_type n) GSL_NOEXCEPT { return *this += -n; }
constexpr difference_type operator-(const span_iterator& rhs) const GSL_NOEXCEPT
constexpr difference_type operator-(span_iterator rhs) const GSL_NOEXCEPT
{
Expects(span_ == rhs.span_);
return index_ - rhs.index_;
@ -210,39 +210,39 @@ namespace details
return *(*this + n);
}
constexpr friend bool operator==(const span_iterator& lhs,
const span_iterator& rhs) GSL_NOEXCEPT
constexpr friend bool operator==(span_iterator lhs,
span_iterator rhs) GSL_NOEXCEPT
{
return lhs.span_ == rhs.span_ && lhs.index_ == rhs.index_;
}
constexpr friend bool operator!=(const span_iterator& lhs,
const span_iterator& rhs) GSL_NOEXCEPT
constexpr friend bool operator!=(span_iterator lhs,
span_iterator rhs) GSL_NOEXCEPT
{
return !(lhs == rhs);
}
constexpr friend bool operator<(const span_iterator& lhs,
const span_iterator& rhs) GSL_NOEXCEPT
constexpr friend bool operator<(span_iterator lhs,
span_iterator rhs) GSL_NOEXCEPT
{
Expects(lhs.span_ == rhs.span_);
return lhs.index_ < rhs.index_;
}
constexpr friend bool operator<=(const span_iterator& lhs,
const span_iterator& rhs) GSL_NOEXCEPT
constexpr friend bool operator<=(span_iterator lhs,
span_iterator rhs) GSL_NOEXCEPT
{
return !(rhs < lhs);
}
constexpr friend bool operator>(const span_iterator& lhs,
const span_iterator& rhs) GSL_NOEXCEPT
constexpr friend bool operator>(span_iterator lhs,
span_iterator rhs) GSL_NOEXCEPT
{
return rhs < lhs;
}
constexpr friend bool operator>=(const span_iterator& lhs,
const span_iterator& rhs) GSL_NOEXCEPT
constexpr friend bool operator>=(span_iterator lhs,
span_iterator rhs) GSL_NOEXCEPT
{
return !(rhs > lhs);
}
@ -255,7 +255,7 @@ namespace details
template <class Span, bool IsConst>
inline constexpr span_iterator<Span, IsConst>
operator+(typename span_iterator<Span, IsConst>::difference_type n,
const span_iterator<Span, IsConst>& rhs) GSL_NOEXCEPT
span_iterator<Span, IsConst> rhs) GSL_NOEXCEPT
{
return rhs + n;
}
@ -263,7 +263,7 @@ namespace details
template <class Span, bool IsConst>
inline constexpr span_iterator<Span, IsConst>
operator-(typename span_iterator<Span, IsConst>::difference_type n,
const span_iterator<Span, IsConst>& rhs) GSL_NOEXCEPT
span_iterator<Span, IsConst> rhs) GSL_NOEXCEPT
{
return rhs - n;
}
@ -535,43 +535,43 @@ private:
// [span.comparison], span comparison operators
template <class ElementType, std::ptrdiff_t FirstExtent, std::ptrdiff_t SecondExtent>
inline constexpr bool operator==(const span<ElementType, FirstExtent>& l,
const span<ElementType, SecondExtent>& r)
inline constexpr bool operator==(span<ElementType, FirstExtent> l,
span<ElementType, SecondExtent> r)
{
return std::equal(l.begin(), l.end(), r.begin(), r.end());
}
template <class ElementType, std::ptrdiff_t Extent>
inline constexpr bool operator!=(const span<ElementType, Extent>& l,
const span<ElementType, Extent>& r)
inline constexpr bool operator!=(span<ElementType, Extent> l,
span<ElementType, Extent> r)
{
return !(l == r);
}
template <class ElementType, std::ptrdiff_t Extent>
inline constexpr bool operator<(const span<ElementType, Extent>& l,
const span<ElementType, Extent>& r)
inline constexpr bool operator<(span<ElementType, Extent> l,
span<ElementType, Extent> r)
{
return std::lexicographical_compare(l.begin(), l.end(), r.begin(), r.end());
}
template <class ElementType, std::ptrdiff_t Extent>
inline constexpr bool operator<=(const span<ElementType, Extent>& l,
const span<ElementType, Extent>& r)
inline constexpr bool operator<=(span<ElementType, Extent> l,
span<ElementType, Extent> r)
{
return !(l > r);
}
template <class ElementType, std::ptrdiff_t Extent>
inline constexpr bool operator>(const span<ElementType, Extent>& l,
const span<ElementType, Extent>& r)
inline constexpr bool operator>(span<ElementType, Extent> l,
span<ElementType, Extent> r)
{
return r < l;
}
template <class ElementType, std::ptrdiff_t Extent>
inline constexpr bool operator>=(const span<ElementType, Extent>& l,
const span<ElementType, Extent>& r)
inline constexpr bool operator>=(span<ElementType, Extent> l,
span<ElementType, Extent> r)
{
return !(l < r);
}
@ -662,7 +662,7 @@ span<typename Ptr::element_type> make_span(Ptr& cont)
// Specialization of gsl::at for span
template <class ElementType, std::ptrdiff_t Extent>
inline constexpr ElementType& at(const span<ElementType, Extent>& s, std::ptrdiff_t index)
inline constexpr ElementType& at(span<ElementType, Extent> s, std::ptrdiff_t index)
{
// No bounds checking here because it is done in span::operator[] called below
return s[index];