[libcxx-commits] [libcxx] [libc++][iterator] Applied `[[nodiscard]]` (PR #172200)

via libcxx-commits libcxx-commits at lists.llvm.org
Sun Dec 14 01:08:35 PST 2025


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/include/__iterator/access.h libcxx/include/__iterator/back_insert_iterator.h libcxx/include/__iterator/bounded_iter.h libcxx/include/__iterator/common_iterator.h libcxx/include/__iterator/counted_iterator.h libcxx/include/__iterator/data.h libcxx/include/__iterator/distance.h libcxx/include/__iterator/front_insert_iterator.h libcxx/include/__iterator/insert_iterator.h libcxx/include/__iterator/istream_iterator.h libcxx/include/__iterator/istreambuf_iterator.h libcxx/include/__iterator/iterator_with_data.h libcxx/include/__iterator/move_iterator.h libcxx/include/__iterator/move_sentinel.h libcxx/include/__iterator/ostream_iterator.h libcxx/include/__iterator/ostreambuf_iterator.h libcxx/include/__iterator/size.h libcxx/test/libcxx/diagnostics/iterator.nodiscard.verify.cpp --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/__iterator/move_iterator.h b/libcxx/include/__iterator/move_iterator.h
index e9d38dd1b..e07535023 100644
--- a/libcxx/include/__iterator/move_iterator.h
+++ b/libcxx/include/__iterator/move_iterator.h
@@ -299,8 +299,9 @@ operator<=>(const move_iterator<_Iter1>& __x,
 
 #ifndef _LIBCPP_CXX03_LANG
 template <class _Iter1, class _Iter2>
-[[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto
-operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) -> decltype(__x.base() - __y.base()) {
+[[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI
+_LIBCPP_CONSTEXPR_SINCE_CXX17 auto operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+    -> decltype(__x.base() - __y.base()) {
   return __x.base() - __y.base();
 }
 #else
@@ -336,7 +337,8 @@ inline constexpr bool disable_sized_sentinel_for<move_iterator<_Iter1>, move_ite
 #endif // _LIBCPP_STD_VER >= 20
 
 template <class _Iter>
-[[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator<_Iter> make_move_iterator(_Iter __i) {
+[[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI
+_LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator<_Iter> make_move_iterator(_Iter __i) {
   return move_iterator<_Iter>(std::move(__i));
 }
 

``````````

</details>


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


More information about the libcxx-commits mailing list