From 0e66c9a9bd9d3efe5e1c1d134819ec23bd792d5d Mon Sep 17 00:00:00 2001 From: mutouyun Date: Sat, 29 Oct 2022 19:32:51 +0800 Subject: [PATCH] fix: [imp] error C3259: 'constexpr' functions can only have one return statement --- include/libimp/span.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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 {