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

Michael Schellenberger Costa via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Apr 4 12:07:14 PDT 2021


miscco added inline comments.


================
Comment at: libcxx/include/iterator:490
+// generated from the primary template, and
+template<typename _Ip>
+requires __is_primary_template<iterator_traits<_Ip>>::value &&
----------------
This should be `class`


================
Comment at: libcxx/include/iterator:492
+requires __is_primary_template<iterator_traits<_Ip>>::value &&
+         (__has_member_difference_type<_Ip> || __has_integral_minus<_Ip>)
+struct __extract_iter_difference_t<_Ip> {
----------------
The `__has_integral_minus` Is not obvious should have add a comment?


================
Comment at: libcxx/include/iterator:551
+template<class>
+struct __extract_iter_value_t;
+
----------------
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


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