[libcxx-commits] [PATCH] D94807: [libc++] Rationalize our treatment of contiguous iterators and __unwrap_iter().

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Feb 3 10:15:48 PST 2021


Quuxplusone added inline comments.


================
Comment at: libcxx/include/iterator:618
+template <class _Up>
+struct __is_cpp17_contiguous_iterator<_Up*> : __has_iterator_category_convertible_to<_Up*, random_access_iterator_tag> {};
 
----------------
ldionne wrote:
> Quuxplusone wrote:
> > ldionne wrote:
> > > I take it that you're not using just `true_type` here in case someone specializes `iterator_traits<MyFoo*>` to have a non random-access `iterator_category`?
> > As the comment indicated, my intent had been to make sure this specialization didn't accidentally accept types like `int(*)()`, `void*`,... which are syntactically `_Up*` but not actually iterators.
> > However, writing tests for this revealed that if you try to ask `__is_cpp17_contiguous_iterator<void*>` it just blows up anyway, because instantiating `iterator_traits<void*>` is ill-formed.
> > So as above, I agree — I'll just do `true_type` here and let someone "fix" the corner case for real, if they ever run into it.
> > 
> > I hadn't realized that `__has_iterator_category_convertible_to` wasn't SFINAE-friendly. (It barfs on most non-iterator types.)
> > I hadn't realized that __has_iterator_category_convertible_to wasn't SFINAE-friendly. (It barfs on most non-iterator types.)
> 
> This is surprising to me. Perhaps we should fix it.
Agreed, but not fixed in this patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94807/new/

https://reviews.llvm.org/D94807



More information about the libcxx-commits mailing list