diff --git a/include/libimp/span.h b/include/libimp/span.h index 2e013a8..c686f8d 100644 --- a/include/libimp/span.h +++ b/include/libimp/span.h @@ -190,22 +190,21 @@ public: return reverse_iterator(this->begin()); } - constexpr span first(size_type count) const noexcept { + constexpr span first(size_type count) const noexcept { return span(begin(), count); } - constexpr span last(size_type count) const noexcept { + constexpr span last(size_type count) const noexcept { return span(end() - count, count); } - constexpr span subspan(size_type offset, size_type count = (std::numeric_limits::max)()) const noexcept { - if (offset >= size()) { - return {}; - } - return span(begin() + offset, (std::min)(size() - offset, count)); + constexpr span subspan(size_type offset, size_type count = (std::numeric_limits::max)()) const noexcept { + return (offset >= size()) ? span() : span(begin() + offset, (std::min)(size() - offset, count)); } }; +/// @brief Support for span equals comparison. + template () == std::declval())> bool operator==(span a, span b) noexcept {