[libcxx-commits] [libcxx] [libc++] Applied `[[nodiscard]]` to `optional::iterator` (PR #198489)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Sun May 31 10:00:43 PDT 2026


================
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: std-at-least-c++20
+
+// <span>
+
+// Check that functions are marked [[nodiscard]]
+
+#include <span>
+#include <vector>
+
+#include "test_macros.h"
+
+void test() {
+  using Container = std::span<std::vector<int>>;
+
+  Container c;
+  Container::iterator it = c.begin();
+
+#if defined(_LIBCPP_ABI_BOUNDED_ITERATORS)
+  ASSERT_SAME_TYPE(Container::iterator, std::__bounded_iter<std::vector<int>*>);
+#else
+#endif
----------------
frederick-vs-ja wrote:

Fine to me. I think in the follow-up PR for wrapping iterators we just need to add tests.

https://github.com/llvm/llvm-project/pull/198489


More information about the libcxx-commits mailing list