[llvm] r207069 - [ADT] Add a generic iterator utility for adapting iterators much like
Chandler Carruth
chandlerc at gmail.com
Thu Apr 24 13:24:43 PDT 2014
On Thu, Apr 24, 2014 at 1:16 PM, David Blaikie <dblaikie at gmail.com> wrote:
> > +/// \brief An iterator type that allows iterating over the pointees via
> some
> > +/// other iterator.
> > +///
> > +/// The typical usage of this is to expose a type that iterates over
> Ts, but
> > +/// which is implemented with some iterator over T*s:
> > +///
> > +/// \code
> > +/// typedef pointee_iterator<SmallVectorImpl<T *>::iterator> iterator;
> > +/// \endcode
> > +template <
> > + typename WrappedIteratorT,
> > + typename T = typename std::remove_pointer<
> > + typename
> std::iterator_traits<WrappedIteratorT>::value_type>::type>
>
> Just as a strawman, how do you feel about:
>
> template <typename WrappedIteratorT, typename T =
> decltype(**std::declval<WrappedIteratorT>())>
>
> I /think/ your version doesn't work for smart pointers, does it?
> (judging by http://en.cppreference.com/w/cpp/types/remove_pointer )
> and this version should.
Entertainingly, I almost used the version you posted prior to getting
std::remove_pointer to work.
I feel strongly that pointee_iterator should work with smart pointers, and
I'm somewhat bummed that std::remove_pointer doesn't work.
How about a slight variation: T =
decltype(*std::declval<WrappedIteratorT::value_type>())
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140424/eaaf705a/attachment.html>
More information about the llvm-commits
mailing list