[PATCH] D25124: Support rvalue references in enumerate range adapter.

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 4 15:56:19 PDT 2016


chandlerc added inline comments.


> STLExtras.h:640-650
> +      : public std::iterator<
> +            std::forward_iterator_tag,
> +            result_pair<
> +                typename std::iterator_traits<IterOfRange<R>>::value_type>,
> +            typename std::iterator_traits<IterOfRange<R>>::difference_type,
> +            result_pair<typename std::iterator_traits<IterOfRange<R>>::pointer>,
> +            result_pair<

Deriving from std::iterator isn't really what you want to do...

What may not be obvious is that in these three typedefs "iterator" refers to the injected class name of the std::iterator base class. You could equivalently write those three typedefs as:

  typedef typename iterator::reference reference;

And so on...

But I don't think you want to try to inherit from std::iterator or typedef any of these things. Your type isn't a forward iterator. It is either an input or output iterator depending on the constness, and it has a few extra features. This will be really hard to model as-is...

I would just make a private typedef for your result type using `std::iterator_traits<IterOfRange<R>>`, and give up nesting enumerates until we completely overhaul how all of this code deals with ranges and iterators. Is there a reason you can't do that?

https://reviews.llvm.org/D25124





More information about the llvm-commits mailing list