[libcxx-commits] [PATCH] D142294: [libc++] Allow transforming to a different type in transform_inclusive_scan
Mark de Wever via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Jan 22 06:13:37 PST 2023
Mordante added inline comments.
================
Comment at: libcxx/include/__numeric/transform_inclusive_scan.h:45
if (__first != __last) {
- typename iterator_traits<_InputIterator>::value_type __init = __u(*__first);
+ auto __init = __u(*__first);
*__result++ = __init;
----------------
I'm not fond of `auto` here.
================
Comment at: libcxx/include/__numeric/transform_inclusive_scan.h:48
if (++__first != __last)
return _VSTD::transform_inclusive_scan(__first, __last, __result, __b, __u, __init);
}
----------------
I'm not sure this approach is valid.
http://eel.is/c++draft/transform.inclusive.scan#3.1
```
If init is provided, T meets the Cpp17MoveConstructible (Table 32) requirements; otherwise, U meets the Cpp17MoveConstructible requirements.
```
If U (decltype(first)) is movable but T (decltype(__init)) isn't this code may violate the precondition. We even require `__init` to be copyable.
I wonder whether that's a bug in the Standard, since I'm unsure how to implement the init version with a non-copyable type. But at least here a copy feels wrong to me.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142294/new/
https://reviews.llvm.org/D142294
More information about the libcxx-commits
mailing list