fix: [imp] error C3259: 'constexpr' functions can only have one return statement

This commit is contained in:
mutouyun 2022-10-29 19:32:51 +08:00
parent a0076f6bfb
commit 0e66c9a9bd

View File

@ -190,22 +190,21 @@ public:
return reverse_iterator(this->begin()); return reverse_iterator(this->begin());
} }
constexpr span<element_type> first(size_type count) const noexcept { constexpr span first(size_type count) const noexcept {
return span(begin(), count); return span(begin(), count);
} }
constexpr span<element_type> last(size_type count) const noexcept { constexpr span last(size_type count) const noexcept {
return span(end() - count, count); return span(end() - count, count);
} }
constexpr span<element_type> subspan(size_type offset, size_type count = (std::numeric_limits<size_type>::max)()) const noexcept { constexpr span subspan(size_type offset, size_type count = (std::numeric_limits<size_type>::max)()) const noexcept {
if (offset >= size()) { return (offset >= size()) ? span() : span(begin() + offset, (std::min)(size() - offset, count));
return {};
}
return span(begin() + offset, (std::min)(size() - offset, count));
} }
}; };
/// @brief Support for span equals comparison.
template <typename T, typename U, template <typename T, typename U,
typename = decltype(std::declval<T>() == std::declval<U>())> typename = decltype(std::declval<T>() == std::declval<U>())>
bool operator==(span<T> a, span<U> b) noexcept { bool operator==(span<T> a, span<U> b) noexcept {