[PATCH] D30853: Improve the genericity of `llvm::enumerate()`.
Zachary Turner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 11 16:34:22 PST 2017
zturner added inline comments.
================
Comment at: llvm/include/llvm/ADT/STLExtras.h:1024
+ typename std::iterator_traits<IterOfRange<R>>::pointer,
+ typename std::iterator_traits<IterOfRange<R>>::reference> {
+ using result_type = result_pair<R>;
----------------
bryant wrote:
> can iterator_adaptor_base be used for this? it looks like its default template params fit.
I was not able to make this work well. `iterator_adapter_base` stores a copy of the iterator While I also want to store a copy of the iterator, I also need to store an index. And I need both to be part of the iterator's `value_type`. So if I want to use `iterator_adapter_base`, It becomes wasteful because I store a copy of the iterator twice. Once in `iterator_adapter_base` and again in the `result` member variable.
https://reviews.llvm.org/D30853
More information about the llvm-commits
mailing list