[libcxx-commits] [PATCH] D99863: [libcxx] adds `iter_difference_t` and `iter_value_t`

Christopher Di Bella via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Apr 4 14:03:20 PDT 2021


cjdb added inline comments.


================
Comment at: libcxx/include/iterator:551
+template<class>
+struct __extract_iter_value_t;
+
----------------
miscco wrote:
> Can we get rid of the `__extract_iter_value_t` struct alltogether and always fall back to an alias?
> 
> 
> ```
> template<class _Ip>
> requires __is_primary_template<iterator_traits<remove_cvref_t<_Ip>>>::value &&
>          __has_member_value_type<indirectly_readable_traits<remove_cvref_t<_Ip>>>
> using iter_value_t = typename indirectly_readable_traits<remove_cvref_t<_Ip>>::value_type;
> 
> template<class _Ip>
> using iter_value_t = typename iterator_traits<remove_cvref_t<_Ip>>::value_type;
> ```
> 
> That way we would get around all those type instantiations, which are quite costly
Aliases can't be specialised. Might be worth a compiler patch to elide this if it's deemed too costly?


================
Comment at: libcxx/test/std/iterators/iterator.requirements/iterator.assoc.types/incrementable.traits/iter_difference_t.fail.cpp:19
+using fails1 = std::iter_difference_t<void>;
+// expected-error at iterator:* {{no type named 'difference_type' in 'std::iterator_traits<void>'}}
+
----------------
Mordante wrote:
> Why not use a specific offset like `expected-errror at -1`?
The error originates from `<iterator>`, not this file (I originally did `expected-error at -1` which is how I learnt about `@iterator:*` when it failed).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99863



More information about the libcxx-commits mailing list