[libcxx-commits] [PATCH] D121130: [libc++] Make common_iterator's proxy types into aggregates
Arthur O'Dwyer via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Mar 7 10:46:39 PST 2022
Quuxplusone added inline comments.
================
Comment at: libcxx/include/__iterator/common_iterator.h:123
} else {
- return __proxy(*_VSTD::__unchecked_get<_Iter>(__hold_));
+ return __proxy{*_VSTD::__unchecked_get<_Iter>(__hold_)};
}
----------------
ldionne wrote:
> Right, so we know that `_VSTD::__unchecked_get<_Iter>(__hold_)` (aka the iterator) has a non-reference `iter_reference_t`, which is a complicated way of saying `*iter` is a temporary. So when we construct the aggregate now, we're even eliding a move operation. That sounds right?
We're replacing a conversion `iter_reference_t&& -> iter_value_t` with a conversion `iter_reference_t -> iter_value_t`. In the case that `iter_reference_t` and `iter_value_t` are the //same// type, this is a savings. Otherwise, AIUI, it's really no different. (But I //imagine// that "they're the same type" is the common case.)
Also in the `__postfix_proxy` case, we're replacing `iter_reference_t&& -> iter_reference_t` with `iter_reference_t -> iter_reference_t`, which definitely saves one move-ctor of whatever type `iter_reference_t` is.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D121130/new/
https://reviews.llvm.org/D121130
More information about the libcxx-commits
mailing list