[libcxx-commits] [libcxx] [libc++][ranges] Applied `[[nodiscard]]` to `views::zip_transform` (PR #207120)

via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 1 22:18:31 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- libcxx/test/libcxx/ranges/range.adaptors/range.zip.transform/nodiscard.verify.cpp libcxx/include/__ranges/zip_transform_view.h --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxx/include/__ranges/zip_transform_view.h b/libcxx/include/__ranges/zip_transform_view.h
index 71849105d..ffa3e9f9c 100644
--- a/libcxx/include/__ranges/zip_transform_view.h
+++ b/libcxx/include/__ranges/zip_transform_view.h
@@ -273,7 +273,8 @@ public:
     return __iterator(*__i.__parent_, __i.__inner_ - __n);
   }
 
-  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type operator-(const __iterator& __x, const __iterator& __y)
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type
+  operator-(const __iterator& __x, const __iterator& __y)
     requires sized_sentinel_for<__ziperator<_Const>, __ziperator<_Const>>
   {
     return __x.__inner_ - __y.__inner_;
diff --git a/libcxx/test/libcxx/ranges/range.adaptors/range.zip.transform/nodiscard.verify.cpp b/libcxx/test/libcxx/ranges/range.adaptors/range.zip.transform/nodiscard.verify.cpp
index 9c8673c60..7d15d027f 100644
--- a/libcxx/test/libcxx/ranges/range.adaptors/range.zip.transform/nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/ranges/range.adaptors/range.zip.transform/nodiscard.verify.cpp
@@ -52,7 +52,7 @@ void test() {
 
   // [range.zip_transform.iterator]
 
-  auto it = ztv.begin();
+  auto it  = ztv.begin();
   auto cIt = std::as_const(ztv).begin();
 
   // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}

``````````

</details>


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


More information about the libcxx-commits mailing list