_LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
{
- static_assert(_Extent > 0, "span<T,N>[].front() on empty span");
+ _LIBCPP_ASSERT(!empty(), "span<T, N>::front() on empty span");
return __data[0];
}
_LIBCPP_INLINE_VISIBILITY constexpr reference back() const noexcept
{
- static_assert(_Extent > 0, "span<T,N>[].back() on empty span");
+ _LIBCPP_ASSERT(!empty(), "span<T, N>::back() on empty span");
return __data[size()-1];
}
return std::addressof(sp.back()) == sp.data() + sp.size() - 1;
}
-
template <typename Span>
void testRuntimeSpan(Span sp)
{
assert(std::addressof(sp.back()) == sp.data() + sp.size() - 1);
}
+template <typename Span>
+void testEmptySpan(Span sp)
+{
+ if (!sp.empty())
+ [[maybe_unused]] auto res = sp.back();
+}
struct A{};
constexpr int iArr1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
testRuntimeSpan(std::span<std::string> (&s, 1));
testRuntimeSpan(std::span<std::string, 1>(&s, 1));
+ std::span<int, 0> sp;
+ testEmptySpan(sp);
+
return 0;
}
assert(std::addressof(sp.front()) == sp.data());
}
+template <typename Span>
+void testEmptySpan(Span sp)
+{
+ if (!sp.empty())
+ [[maybe_unused]] auto res = sp.front();
+}
struct A{};
constexpr int iArr1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
testRuntimeSpan(std::span<std::string> (&s, 1));
testRuntimeSpan(std::span<std::string, 1>(&s, 1));
+ std::span<int, 0> sp;
+ testEmptySpan(sp);
+
return 0;
}