[libcxx-commits] [libcxx] [libc++] Add [[nodiscard]] to std::prev and std::next (PR #109550)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Sep 25 13:51:50 PDT 2024


================
@@ -43,25 +43,26 @@ next(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n =
 namespace ranges {
 struct __next {
   template <input_or_output_iterator _Ip>
-  _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x) const {
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x) const {
     ++__x;
     return __x;
----------------
ldionne wrote:

Not attached to this line: Can you please add tests for this? It should be sufficient to add entries for `std::next`, `std::prev` and their ranges counterparts in `libcxx/test/libcxx/diagnostics/iterator.nodiscard.verify.cpp`.

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


More information about the libcxx-commits mailing list