Skip to content

Commit ea7e0a7

Browse files
committed
[libc++] Add [[nodiscard]] to std::prev and std::next
1 parent 7645d9c commit ea7e0a7

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

libcxx/include/__iterator/next.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,25 @@ next(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n =
4343
namespace ranges {
4444
struct __next {
4545
template <input_or_output_iterator _Ip>
46-
_LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x) const {
46+
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x) const {
4747
++__x;
4848
return __x;
4949
}
5050

5151
template <input_or_output_iterator _Ip>
52-
_LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n) const {
52+
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n) const {
5353
ranges::advance(__x, __n);
5454
return __x;
5555
}
5656

5757
template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
58-
_LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, _Sp __bound_sentinel) const {
58+
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, _Sp __bound_sentinel) const {
5959
ranges::advance(__x, __bound_sentinel);
6060
return __x;
6161
}
6262

6363
template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
64-
_LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Sp __bound_sentinel) const {
64+
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Sp __bound_sentinel) const {
6565
ranges::advance(__x, __n, __bound_sentinel);
6666
return __x;
6767
}

libcxx/include/__iterator/prev.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,19 @@ prev(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n =
4242
namespace ranges {
4343
struct __prev {
4444
template <bidirectional_iterator _Ip>
45-
_LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x) const {
45+
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x) const {
4646
--__x;
4747
return __x;
4848
}
4949

5050
template <bidirectional_iterator _Ip>
51-
_LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n) const {
51+
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n) const {
5252
ranges::advance(__x, -__n);
5353
return __x;
5454
}
5555

5656
template <bidirectional_iterator _Ip>
57-
_LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Ip __bound_iter) const {
57+
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Ip __bound_iter) const {
5858
ranges::advance(__x, -__n, __bound_iter);
5959
return __x;
6060
}

0 commit comments

Comments
 (0)