mirror of
https://github.com/microsoft/GSL.git
synced 2025-11-17 15:59:22 +01:00
Implemented comparison operators on array_view.
This commit is contained in:
@@ -1420,11 +1420,42 @@ public:
|
||||
}
|
||||
|
||||
template <typename OtherValueType, typename OtherBoundsType, typename Dummy = std::enable_if_t<std::is_same<std::remove_cv_t<value_type>, std::remove_cv_t<OtherValueType>>::value>>
|
||||
_CONSTEXPR auto operator == (const basic_array_view<OtherValueType, OtherBoundsType> & other) const -> decltype(this->m_pdata == other.m_pdata && this->m_bounds == other.m_bounds) _NOEXCEPT
|
||||
_CONSTEXPR bool operator== (const basic_array_view<OtherValueType, OtherBoundsType> & other) const _NOEXCEPT
|
||||
{
|
||||
return m_pdata == other.m_pdata && m_bounds == other.m_bounds;
|
||||
return m_bounds.size() == other.m_bounds.size() &&
|
||||
(m_pdata == other.m_pdata || std::equal(this->begin(), this->end(), other.begin(), other.end()));
|
||||
}
|
||||
|
||||
template <typename OtherValueType, typename OtherBoundsType, typename Dummy = std::enable_if_t<std::is_same<std::remove_cv_t<value_type>, std::remove_cv_t<OtherValueType>>::value>>
|
||||
_CONSTEXPR bool operator!= (const basic_array_view<OtherValueType, OtherBoundsType> & other) const _NOEXCEPT
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
template <typename OtherValueType, typename OtherBoundsType, typename Dummy = std::enable_if_t<std::is_same<std::remove_cv_t<value_type>, std::remove_cv_t<OtherValueType>>::value>>
|
||||
_CONSTEXPR bool operator< (const basic_array_view<OtherValueType, OtherBoundsType> & other) const _NOEXCEPT
|
||||
{
|
||||
return std::lexicographical_compare(this->begin(), this->end(), other.begin(), other.end());
|
||||
}
|
||||
|
||||
template <typename OtherValueType, typename OtherBoundsType, typename Dummy = std::enable_if_t<std::is_same<std::remove_cv_t<value_type>, std::remove_cv_t<OtherValueType>>::value>>
|
||||
_CONSTEXPR bool operator<= (const basic_array_view<OtherValueType, OtherBoundsType> & other) const _NOEXCEPT
|
||||
{
|
||||
return !(other < *this);
|
||||
}
|
||||
|
||||
template <typename OtherValueType, typename OtherBoundsType, typename Dummy = std::enable_if_t<std::is_same<std::remove_cv_t<value_type>, std::remove_cv_t<OtherValueType>>::value>>
|
||||
_CONSTEXPR bool operator> (const basic_array_view<OtherValueType, OtherBoundsType> & other) const _NOEXCEPT
|
||||
{
|
||||
return (other < *this);
|
||||
}
|
||||
|
||||
template <typename OtherValueType, typename OtherBoundsType, typename Dummy = std::enable_if_t<std::is_same<std::remove_cv_t<value_type>, std::remove_cv_t<OtherValueType>>::value>>
|
||||
_CONSTEXPR bool operator>= (const basic_array_view<OtherValueType, OtherBoundsType> & other) const _NOEXCEPT
|
||||
{
|
||||
return !(*this < other);
|
||||
}
|
||||
|
||||
public:
|
||||
template <typename OtherValueType, typename OtherBounds,
|
||||
typename Dummy = std::enable_if_t<std::is_convertible<OtherValueType(*)[], value_type(*)[]>::value
|
||||
@@ -1795,6 +1826,13 @@ public:
|
||||
{
|
||||
return { &this->operator[](origin), strided_bounds<rank, size_type> {extents, details::make_stride(Base::bounds())}};
|
||||
}
|
||||
|
||||
using Base::operator==;
|
||||
using Base::operator!=;
|
||||
using Base::operator<;
|
||||
using Base::operator<=;
|
||||
using Base::operator>;
|
||||
using Base::operator>=;
|
||||
};
|
||||
|
||||
template <typename T, size_t... Dimensions>
|
||||
|
||||
Reference in New Issue
Block a user