`__iterator/readable_traits.h` can't be used by itself, intantiating `iter_value_t` requires `__iterator/iterator_traits.h`. `readable_traits.h` can't include `iterator_traits.h` though because `iterator_traits.h` requires `readable_traits.h`.
Move `iter_value_t` to `__iterator/iterator_traits.h` so that both headers can work standalone.
Reviewed By: Mordante, #libc
Differential Revision: https://reviews.llvm.org/D153828
#include <__iterator/concepts.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/projected.h>
-#include <__iterator/readable_traits.h>
#include <__ranges/access.h>
#include <__ranges/concepts.h>
#include <__ranges/dangling.h>
#include <__iterator/back_insert_iterator.h>
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>
-#include <__iterator/readable_traits.h> // iter_value_t
+#include <__iterator/iterator_traits.h> // iter_value_t
#include <__variant/monostate.h>
#include <array>
#include <string>
#include <__config>
#include <__format/format_error.h>
#include <__iterator/concepts.h>
-#include <__iterator/readable_traits.h> // iter_value_t
+#include <__iterator/iterator_traits.h> // iter_value_t
#include <cstddef>
#include <cstdint>
#include <__format/unicode.h>
#include <__iterator/back_insert_iterator.h>
#include <__iterator/concepts.h>
-#include <__iterator/readable_traits.h> // iter_value_t
+#include <__iterator/iterator_traits.h> // iter_value_t
#include <__system_error/errc.h>
#include <__type_traits/make_unsigned.h>
#include <__utility/move.h>
#include <__format/unicode.h>
#include <__format/width_estimation_table.h>
#include <__iterator/concepts.h>
-#include <__iterator/readable_traits.h> // iter_value_t
+#include <__iterator/iterator_traits.h> // iter_value_t
#include <__memory/addressof.h>
#include <__type_traits/common_type.h>
#include <__type_traits/is_trivially_copyable.h>
#include <__config>
#include <__format/extended_grapheme_cluster_table.h>
#include <__iterator/concepts.h>
-#include <__iterator/readable_traits.h> // iter_value_t
+#include <__iterator/iterator_traits.h> // iter_value_t
#include <__type_traits/make_unsigned.h>
#include <__utility/unreachable.h>
#include <string_view>
template <class _Iter>
using __iter_reference = typename iterator_traits<_Iter>::reference;
+#if _LIBCPP_STD_VER >= 20
+
+// [readable.traits]
+
+// Let `RI` be `remove_cvref_t<I>`. The type `iter_value_t<I>` denotes
+// `indirectly_readable_traits<RI>::value_type` if `iterator_traits<RI>` names a specialization
+// generated from the primary template, and `iterator_traits<RI>::value_type` otherwise.
+// This has to be in this file and not readable_traits.h to break the include cycle between the two.
+template <class _Ip>
+using iter_value_t = typename conditional_t<__is_primary_template<iterator_traits<remove_cvref_t<_Ip> > >::value,
+ indirectly_readable_traits<remove_cvref_t<_Ip> >,
+ iterator_traits<remove_cvref_t<_Ip> > >::value_type;
+
+#endif // _LIBCPP_STD_VER >= 20
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___ITERATOR_ITERATOR_TRAITS_H
struct indirectly_readable_traits<_Tp>
: __cond_value_type<typename _Tp::value_type> {};
-template <class>
-struct iterator_traits;
-
-// Let `RI` be `remove_cvref_t<I>`. The type `iter_value_t<I>` denotes
-// `indirectly_readable_traits<RI>::value_type` if `iterator_traits<RI>` names a specialization
-// generated from the primary template, and `iterator_traits<RI>::value_type` otherwise.
-template <class _Ip>
-using iter_value_t = typename conditional_t<__is_primary_template<iterator_traits<remove_cvref_t<_Ip> > >::value,
- indirectly_readable_traits<remove_cvref_t<_Ip> >,
- iterator_traits<remove_cvref_t<_Ip> > >::value_type;
-
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
#include <__concepts/destructible.h>
#include <__config>
#include <__iterator/incrementable_traits.h>
-#include <__iterator/readable_traits.h>
+#include <__iterator/iterator_traits.h>
#include <__memory/concepts.h>
#include <__memory/construct_at.h>
#include <__ranges/access.h>
#include <__fwd/string_view.h>
#include <__iterator/bounded_iter.h>
#include <__iterator/concepts.h>
-#include <__iterator/readable_traits.h>
+#include <__iterator/iterator_traits.h>
#include <__iterator/reverse_iterator.h>
#include <__memory/pointer_traits.h>
#include <__ranges/concepts.h>