[libcxx-commits] [libcxx] [libc++] Applied `[[nodiscard]]` to `optional::iterator` (PR #198489)
Hristo Hristov via libcxx-commits
libcxx-commits at lists.llvm.org
Fri May 29 22:03:07 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
----------------
Zingam wrote:
In the spirit of https://github.com/llvm/llvm-project/pull/198492 I'd like to keep this strictly related to `std::optional`. I'll be adding the remaining bits in followups.
https://github.com/llvm/llvm-project/pull/198489
More information about the libcxx-commits
mailing list