1616
1717#include < __algorithm/ranges_copy.h>
1818#include < __chrono/statically_widen.h>
19- #include < __concepts/same_as.h>
2019#include < __config>
2120#include < __format/concepts.h>
2221#include < __format/formatter.h>
22+ #include < __format/range_format.h>
2323#include < __format/range_formatter.h>
2424#include < __iterator/back_insert_iterator.h>
2525#include < __ranges/concepts.h>
@@ -42,51 +42,11 @@ concept __const_formattable_range =
4242template <class _Rp , class _CharT >
4343using __fmt_maybe_const _LIBCPP_NODEBUG = conditional_t <__const_formattable_range<_Rp, _CharT>, const _Rp, _Rp>;
4444
45- _LIBCPP_DIAGNOSTIC_PUSH
46- _LIBCPP_CLANG_DIAGNOSTIC_IGNORED (" -Wshadow" )
47- _LIBCPP_GCC_DIAGNOSTIC_IGNORED(" -Wshadow" )
48- // This shadows map, set, and string.
49- enum class range_format { disabled, map, set, sequence, string, debug_string };
50- _LIBCPP_DIAGNOSTIC_POP
51-
5245// There is no definition of this struct, it's purely intended to be used to
5346// generate diagnostics.
5447template <class _Rp >
5548struct __instantiated_the_primary_template_of_format_kind ;
5649
57- template <class _Rp >
58- constexpr range_format format_kind = [] {
59- // [format.range.fmtkind]/1
60- // A program that instantiates the primary template of format_kind is ill-formed.
61- static_assert (sizeof (_Rp) != sizeof (_Rp), " create a template specialization of format_kind for your type" );
62- return range_format::disabled;
63- }();
64-
65- template <ranges::input_range _Rp>
66- requires same_as<_Rp, remove_cvref_t <_Rp>>
67- inline constexpr range_format format_kind<_Rp> = [] {
68- // [format.range.fmtkind]/2
69-
70- // 2.1 If same_as<remove_cvref_t<ranges::range_reference_t<R>>, R> is true,
71- // Otherwise format_kind<R> is range_format::disabled.
72- if constexpr (same_as<remove_cvref_t <ranges::range_reference_t <_Rp>>, _Rp>)
73- return range_format::disabled;
74- // 2.2 Otherwise, if the qualified-id R::key_type is valid and denotes a type:
75- else if constexpr (requires { typename _Rp::key_type; }) {
76- // 2.2.1 If the qualified-id R::mapped_type is valid and denotes a type ...
77- if constexpr (requires { typename _Rp::mapped_type; } &&
78- // 2.2.1 ... If either U is a specialization of pair or U is a specialization
79- // of tuple and tuple_size_v<U> == 2
80- __fmt_pair_like<remove_cvref_t <ranges::range_reference_t <_Rp>>>)
81- return range_format::map;
82- else
83- // 2.2.2 Otherwise format_kind<R> is range_format::set.
84- return range_format::set;
85- } else
86- // 2.3 Otherwise, format_kind<R> is range_format::sequence.
87- return range_format::sequence;
88- }();
89-
9050template <range_format _Kp, ranges::input_range _Rp, class _CharT >
9151struct __range_default_formatter ;
9252
0 commit comments