[PATCH] D25124: Support rvalue references in enumerate range adapter.
Chandler Carruth via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 1 20:08:38 PDT 2016
chandlerc added inline comments.
> STLExtras.h:641
> struct iterator {
> - iterator(I Iter, std::size_t Index) : Iter(Iter), Index(Index) {}
> -
> - result_pair<const V> operator*() const {
> - return result_pair<const V>(Index, *Iter);
> + public:
> + // std::declval<R>() will return an R&&, which causes std::begin() to return
No need for public? This is a struct...
> STLExtras.h:642-646
> + // std::declval<R>() will return an R&&, which causes std::begin() to return
> + // a const_iterator. Since the storage for the underlying range is an
> + // lvalue, enforce this with std::declval<R&>().
> + using I = decltype(std::begin(std::declval<R &>()));
> + using V = typename std::remove_const<decltype(*std::declval<I>())>::type;
I don't really understand this comment or the remove_const below...
For example, does the remove_const cause this to allow mutation even when the range itself doesn't? That doesn't seem good...
(also, 80 columns)
> STLExtras.h:651-653
> + // result_pair<const V> operator*() const {
> + // return result_pair<const V>(Index, *Iter);
> + //}
?
https://reviews.llvm.org/D25124
More information about the llvm-commits
mailing list