[libcxx-commits] [PATCH] D99873: [libcxx] adds `std::ranges::iter_move` and `std::iter_rvalue_reference_t`

Christopher Di Bella via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Apr 17 19:15:50 PDT 2021


cjdb added inline comments.


================
Comment at: libcxx/include/__iterator/iter_move.h:59
+  constexpr decltype(auto) operator()(_Ip&& __i) const
+    noexcept(noexcept(*_VSTD::forward<_Ip>(__i)))
+  {
----------------
Quuxplusone wrote:
> cjdb wrote:
> > This noexcept specifier doesn't account for a throwing move.
> "`move` doesn't move," and this function returns `decltype(auto)`, so I think we're okay here. This function either returns an rvalue reference in the `if`, or URVOs a prvalue in the `else`.
@rsmith is the one who pointed it out to me, so I'm not so sure. Granted, the tests cover seem to be passing, but a looking over them again makes me realise I only tested noexcept specifiers in one direction. We'll need to plug those holes at the very least.


================
Comment at: libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.move/iter_move.pass.cpp:186
+  static_assert(check_iter_move());
+  assert(check_iter_move());
+
----------------
Quuxplusone wrote:
> zoecarver wrote:
> > cjdb wrote:
> > > zoecarver wrote:
> > > > ldionne wrote:
> > > > > cjdb wrote:
> > > > > > zoecarver wrote:
> > > > > > > No need to call assert here. 
> > > > > > Don't we want to check the run-time value as well?
> > > > > Yes, I think we do. I'm leaving the `assert` in place.
> > > > Why do we want to check the runtime value? The end of `check_iter_move` is `return true;` we're not "checking" anything. 
> > > Sure, but the contents of `check_iter_move` need to be evaluated at both compile-time and run-time.
> > I agree. But why can't you just call `check_iter_move` normally? Why do you need the assert? 
> +1 @zoecarver 
Oh, you're talking about literally removing `assert`, not what's inside it. I'm okay with that!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99873/new/

https://reviews.llvm.org/D99873



More information about the libcxx-commits mailing list