[libcxx-commits] [PATCH] D111516: [libc++][docs] Mark LWG3274 as complete
Joe Loser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Oct 11 08:00:45 PDT 2021
jloser updated this revision to Diff 378666.
jloser edited the summary of this revision.
jloser added a comment.
Mark `span::empty` as `[[nodiscard]]` and add tests.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111516/new/
https://reviews.llvm.org/D111516
Files:
libcxx/docs/Status/Cxx20Issues.csv
libcxx/include/span
libcxx/test/std/containers/views/span.obs/empty.nodiscard.verify.cpp
libcxx/test/std/containers/views/span.obs/empty.pass.cpp
Index: libcxx/test/std/containers/views/span.obs/empty.pass.cpp
===================================================================
--- libcxx/test/std/containers/views/span.obs/empty.pass.cpp
+++ libcxx/test/std/containers/views/span.obs/empty.pass.cpp
@@ -13,7 +13,7 @@
// <span>
-// constexpr bool empty() const noexcept;
+// [[nodiscard]] constexpr bool empty() const noexcept;
//
Index: libcxx/test/std/containers/views/span.obs/empty.nodiscard.verify.cpp
===================================================================
--- /dev/null
+++ libcxx/test/std/containers/views/span.obs/empty.nodiscard.verify.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: libcpp-has-no-incomplete-ranges
+
+// AppleClang 12.0.0 doesn't fully support ranges/concepts
+// XFAIL: apple-clang-12.0.0
+
+// <span>
+
+// [[nodiscard]] constexpr bool empty() const noexcept;
+//
+
+
+#include <span>
+
+void test() {
+ std::span<int> s1;
+ s1.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+ int arr[] = {1, 2, 3};
+ std::span<int, 3> s2{arr};
+ s2.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+}
Index: libcxx/include/span
===================================================================
--- libcxx/include/span
+++ libcxx/include/span
@@ -89,7 +89,7 @@
// [span.obs], span observers
constexpr size_type size() const noexcept;
constexpr size_type size_bytes() const noexcept;
- constexpr bool empty() const noexcept;
+ [[nodiscard]] constexpr bool empty() const noexcept;
// [span.elem], span element access
constexpr reference operator[](size_type idx) const;
@@ -332,7 +332,7 @@
_LIBCPP_INLINE_VISIBILITY constexpr size_type size() const noexcept { return _Extent; }
_LIBCPP_INLINE_VISIBILITY constexpr size_type size_bytes() const noexcept { return _Extent * sizeof(element_type); }
- _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return _Extent == 0; }
+ [[nodiscard]] _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return _Extent == 0; }
_LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept
{
@@ -503,7 +503,7 @@
_LIBCPP_INLINE_VISIBILITY constexpr size_type size() const noexcept { return __size; }
_LIBCPP_INLINE_VISIBILITY constexpr size_type size_bytes() const noexcept { return __size * sizeof(element_type); }
- _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return __size == 0; }
+ [[nodiscard]] _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return __size == 0; }
_LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept
{
Index: libcxx/docs/Status/Cxx20Issues.csv
===================================================================
--- libcxx/docs/Status/Cxx20Issues.csv
+++ libcxx/docs/Status/Cxx20Issues.csv
@@ -183,7 +183,7 @@
"`3272 <https://wg21.link/LWG3272>`__","``%I%p``\ should parse/format ``duration``\ since midnight","Belfast","",""
"`3259 <https://wg21.link/LWG3259>`__","The definition of *constexpr iterators* should be adjusted","Belfast","",""
"`3103 <https://wg21.link/LWG3103>`__","Errors in taking subview of ``span``\ should be ill-formed where possible","Belfast","",""
-"`3274 <https://wg21.link/LWG3274>`__","Missing feature test macro for ``<span>``\ ","Belfast","",""
+"`3274 <https://wg21.link/LWG3274>`__","Missing feature test macro for ``<span>``\ ","Belfast","|Complete|","11.0"
"`3276 <https://wg21.link/LWG3276>`__","Class ``split_view::outer_iterator::value_type``\ should inherit from ``view_interface``\ ","Belfast","",""
"`3277 <https://wg21.link/LWG3277>`__","Pre-increment on prvalues is not a requirement of ``weakly_incrementable``\ ","Belfast","",""
"`3149 <https://wg21.link/LWG3149>`__","``DefaultConstructible``\ should require default initialization","Belfast","|Complete|","13.0"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111516.378666.patch
Type: text/x-patch
Size: 4449 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211011/41674971/attachment.bin>
More information about the libcxx-commits
mailing list