[libcxx-commits] [libcxx] [libc++][vector] Apply `[[nodiscard]]` to `vector<bool>::iterator` (PR #202265)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Jun 7 23:33:47 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 -- libcxx/test/libcxx/containers/sequences/vector.bool/nodiscard.iterator.verify.cpp libcxx/include/__bit_reference --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/__bit_reference b/libcxx/include/__bit_reference
index 3b3ff67de..692686f15 100644
--- a/libcxx/include/__bit_reference
+++ b/libcxx/include/__bit_reference
@@ -389,13 +389,15 @@ public:
return *this += -__n;
}
- [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator operator+(difference_type __n) const {
+ [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator
+ operator+(difference_type __n) const {
__bit_iterator __t(*this);
__t += __n;
return __t;
}
- [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator operator-(difference_type __n) const {
+ [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator
+ operator-(difference_type __n) const {
__bit_iterator __t(*this);
__t -= __n;
return __t;
@@ -411,7 +413,8 @@ public:
return (__x.__seg_ - __y.__seg_) * __bits_per_word + __x.__ctz_ - __y.__ctz_;
}
- [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator[](difference_type __n) const {
+ [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference
+ operator[](difference_type __n) const {
return *(*this + __n);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/202265
More information about the libcxx-commits
mailing list