[libc++] __iterator/readable_traits.h isn't standalone
authorIan Anderson <iana@apple.com>
Mon, 26 Jun 2023 21:07:50 +0000 (14:07 -0700)
committerIan Anderson <iana@apple.com>
Tue, 27 Jun 2023 17:52:08 +0000 (10:52 -0700)
`__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

libcxx/include/__algorithm/ranges_unique_copy.h
libcxx/include/__format/format_functions.h
libcxx/include/__format/format_string.h
libcxx/include/__format/formatter_output.h
libcxx/include/__format/parser_std_format_spec.h
libcxx/include/__format/unicode.h
libcxx/include/__iterator/iterator_traits.h
libcxx/include/__iterator/readable_traits.h
libcxx/include/__memory/ranges_construct_at.h
libcxx/include/string_view

index 803ddca..7e89f9d 100644 (file)
@@ -21,7 +21,6 @@
 #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>
index c8b5904..0e89ef9 100644 (file)
@@ -36,7 +36,7 @@
 #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>
index bec3fe1..4d787ca 100644 (file)
@@ -14,7 +14,7 @@
 #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>
 
index 2a26ce8..85f4577 100644 (file)
@@ -28,7 +28,7 @@
 #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>
index f3f7bce..35facba 100644 (file)
@@ -31,7 +31,7 @@
 #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>
index c6a124e..f7ff2ab 100644 (file)
@@ -16,7 +16,7 @@
 #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>
index a81f0b5..248987e 100644 (file)
@@ -534,6 +534,21 @@ using __iter_diff_t = typename iterator_traits<_Iter>::difference_type;
 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
index fe4f0cd..9e101fc 100644 (file)
@@ -74,17 +74,6 @@ template<__has_member_value_type _Tp>
 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
index 9ded2fc..1ce1327 100644 (file)
@@ -13,7 +13,7 @@
 #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>
index 2cdad44..38a9313 100644 (file)
@@ -210,7 +210,7 @@ namespace std {
 #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>