[libcxx-commits] [libcxx] [libc++] Merge the private iterator_traits aliases with their ranges versions (PR #162661)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Oct 15 08:44:02 PDT 2025
================
@@ -71,15 +65,9 @@ struct _ClassicAlgPolicy {};
template <>
struct _IterOps<_ClassicAlgPolicy> {
- template <class _Iter>
- using __value_type _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::value_type;
----------------
ldionne wrote:
Why is it okay to make this (general) change? I understand that we are probably just accepting more code than previously, but it is possible for conforming C++20 code to break when we do this?
A few questions:
- In C++20, is it possible for an iterator to have different types for `std::iter_value_t<It>` and `std::iterator_traits<It>::value_type`?
- If so, is it possible for these two types to differ to the extent that a classic algorithm (which should in principle use `iterator_traits`, or at least did historically) would break if we start using `std::iter_value_t<It>` instead?
- If it's possible for these two typedefs to differ *and* to the extent of code breaking, are these cases so far fetched that we don't care to support them?
- The same set of questions holds for every nested typedef we're modifying here.
Also CC @frederick-vs-ja since I think I remember having that discussion in a previous patch.
https://github.com/llvm/llvm-project/pull/162661
More information about the libcxx-commits
mailing list