mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Added comparison operators.
This commit is contained in:
parent
25ff7eca1f
commit
d63c9803da
@ -481,26 +481,30 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#if 0 // TODO
|
||||
// [span.comparison], span comparison operators
|
||||
template <class ElementType, ptrdiff_t Extent>
|
||||
constexpr bool operator==(const span<ElementType, Extent>& l, const span<ElementType, Extent>& r) const noexcept;
|
||||
constexpr bool operator==(const span<ElementType, Extent>& l, const span<ElementType, Extent>& r) noexcept
|
||||
{ return std::equal(l.begin(), l.end(), r.begin(), r.end()); }
|
||||
|
||||
template <class ElementType, ptrdiff_t Extent>
|
||||
constexpr bool operator!=(const span<ElementType, Extent>& l, const span<ElementType, Extent>& r) const noexcept;
|
||||
constexpr bool operator!=(const span<ElementType, Extent>& l, const span<ElementType, Extent>& r) noexcept
|
||||
{ return !(l == r); }
|
||||
|
||||
template <class ElementType, ptrdiff_t Extent>
|
||||
constexpr bool operator<(const span<ElementType, Extent>& l, const span<ElementType, Extent>& r) const noexcept;
|
||||
constexpr bool operator<(const span<ElementType, Extent>& l, const span<ElementType, Extent>& r) noexcept
|
||||
{ return std::lexicographical_compare(l.begin(), l.end(), r.begin(), r.end()); }
|
||||
|
||||
template <class ElementType, ptrdiff_t Extent>
|
||||
constexpr bool operator<=(const span<ElementType, Extent>& l, const span<ElementType, Extent>& r) const noexcept;
|
||||
constexpr bool operator<=(const span<ElementType, Extent>& l, const span<ElementType, Extent>& r) noexcept
|
||||
{ return !(l > r); }
|
||||
|
||||
template <class ElementType, ptrdiff_t Extent>
|
||||
constexpr bool operator>(const span<ElementType, Extent>& l, const span<ElementType, Extent>& r) const noexcept;
|
||||
constexpr bool operator>(const span<ElementType, Extent>& l, const span<ElementType, Extent>& r) noexcept
|
||||
{ return r < l; }
|
||||
|
||||
template <class ElementType, ptrdiff_t Extent>
|
||||
constexpr bool operator>=(const span<ElementType, Extent>& l, const span<ElementType, Extent>& r) const noexcept;
|
||||
#endif
|
||||
constexpr bool operator>=(const span<ElementType, Extent>& l, const span<ElementType, Extent>& r) noexcept
|
||||
{ return !(l < r); }
|
||||
|
||||
|
||||
#if 0 // TODO
|
||||
|
@ -801,23 +801,30 @@ SUITE(span_tests)
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
TEST(comparison_operators)
|
||||
{
|
||||
{
|
||||
int arr[10][2];
|
||||
auto s1 = as_span(arr);
|
||||
span<const int, dynamic_range, 2> s2 = s1;
|
||||
|
||||
span<int> s1 = nullptr;
|
||||
span<int> s2 = nullptr;
|
||||
CHECK(s1 == s2);
|
||||
|
||||
span<int, 20> s3 = as_span(s1, dim<>(20));
|
||||
CHECK(s3 == s2 && s3 == s1);
|
||||
CHECK(!(s1 != s2));
|
||||
CHECK(!(s1 < s2));
|
||||
CHECK(s1 <= s2);
|
||||
CHECK(!(s1 > s2));
|
||||
CHECK(s1 >= s2);
|
||||
CHECK(s2 == s1);
|
||||
CHECK(!(s2 != s1));
|
||||
CHECK(!(s2 < s1));
|
||||
CHECK(s2 <= s1);
|
||||
CHECK(!(s2 > s1));
|
||||
CHECK(s2 >= s1);
|
||||
}
|
||||
|
||||
{
|
||||
auto s1 = nullptr;
|
||||
auto s2 = nullptr;
|
||||
int arr[] = {2, 1};
|
||||
span<int> s1 = arr;
|
||||
span<int> s2 = arr;
|
||||
|
||||
CHECK(s1 == s2);
|
||||
CHECK(!(s1 != s2));
|
||||
CHECK(!(s1 < s2));
|
||||
@ -914,6 +921,7 @@ SUITE(span_tests)
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
TEST(fixed_size_conversions)
|
||||
{
|
||||
int arr[] = {1, 2, 3, 4};
|
||||
|
Loading…
Reference in New Issue
Block a user