[libcxx-commits] [PATCH] D102789: [libcxx][iterator] adds `std::ranges::distance`
Christopher Di Bella via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jun 2 10:34:53 PDT 2021
cjdb planned changes to this revision.
cjdb added a comment.
Changes to be applied in the next day or so.
================
Comment at: libcxx/include/__iterator/distance.h:35
+ template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
+ [[nodiscard]] constexpr iter_difference_t<_Ip> operator()(_Ip __first, _Sp __last) const {
+ if constexpr (sized_sentinel_for<_Sp, _Ip>) {
----------------
ldionne wrote:
> Drop `[[nodiscard]]`
After much deliberation on this, I think it's worth considering that we keep `[[nodiscard]]` on anything that consumes a proper `input_iterator` or `output_iterator`. Two reasons:
* they could be move-only (thus the result is lost forever)
*
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102789/new/
https://reviews.llvm.org/D102789
More information about the libcxx-commits
mailing list