[libcxx-commits] [PATCH] D103056: [libcxx][ranges] Add `ranges::transform_view`.
Tim Song via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jul 1 12:42:12 PDT 2021
tcanens added inline comments.
================
Comment at: libcxx/include/__ranges/transform_view.h:289
+ friend constexpr decltype(auto) iter_move(const __iterator& __i)
+ noexcept(noexcept(*__i))
+ {
----------------
ldionne wrote:
> As it stands, I believe the Spec has an issue. CC @tcanens . I think `iter_move(transform_view::iterator)` is never `noexcept`. It is defined in http://eel.is/c++draft/range.transform.iterator as:
>
> ```
> constexpr decltype(auto) iter_move(const transform_view::iterator& i)
> noexcept(noexcept(invoke(*i.parent_->fun_, *i.current_))) {
> if constexpr (is_lvalue_reference_v<decltype(*i)>)
> return std::move(*i);
> else
> return *i;
> }
> ```
>
> However, `*i.parent_->fun_` dereferences the `copyable-box` holding the function object, but `copyable-box` is specified to have the same API as `std::optional`. In the spec, `std::optional::operator*` is not `noexcept`, so the whole `noexcept(noexcept(invoke(*i.parent_->fun_, *i.current_)))` is always `noexcept(false)` unless the library provides a `noexcept` `std::optional::operator*` as an extension.
>
> @tcanens Does that make sense? Is this LWG issue worthy?
>
> (marking as Done since it's not an issue with this review per se).
This will be fixed by https://cplusplus.github.io/LWG/issue2762
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D103056/new/
https://reviews.llvm.org/D103056
More information about the libcxx-commits
mailing list