8#include "format/format_frontend_detail.hpp"
13template <Pr
int::Text Source>
18 inline static constexpr auto source_analysis =
21 static_assert(source_analysis.error != SourceError::NumberOverflow,
22 "LibXR::Format: index, width, or precision is too large");
23 static_assert(source_analysis.error != SourceError::UnexpectedEnd,
24 "LibXR::Format: unexpected end of format string");
26 source_analysis.error != SourceError::EmbeddedNul,
27 "LibXR::Format: embedded NUL bytes are not supported in the format literal");
28 static_assert(source_analysis.error != SourceError::UnmatchedBrace,
29 "LibXR::Format: unmatched brace in format string");
30 static_assert(source_analysis.error != SourceError::MixedIndexing,
31 "LibXR::Format: automatic and manual argument indexing cannot be mixed");
33 source_analysis.error != SourceError::ManualIndexingDisabled,
34 "LibXR::Format: explicit argument indexing is disabled in the current profile");
35 static_assert(source_analysis.error != SourceError::DynamicField,
36 "LibXR::Format: dynamic width and precision are not supported");
37 static_assert(source_analysis.error != SourceError::InvalidArgumentIndex,
38 "LibXR::Format: invalid argument index");
39 static_assert(source_analysis.error != SourceError::InvalidSpecifier,
40 "LibXR::Format: invalid format specifier");
41 static_assert(source_analysis.error != SourceError::InvalidPresentation,
42 "LibXR::Format: invalid presentation type");
57 template <
typename... Args>
66 template <
typename... Args>
73 static_assert(source_analysis.error != SourceError::None ||
74 sizeof...(Args) == source_analysis.required_argument_count,
75 "LibXR::Format: call-site argument count does not match the "
76 "referenced replacement fields");
77 static_assert(result.compile_error != Error::NumberOverflow,
78 "LibXR::Format: index, width, or precision is too large");
79 static_assert(result.compile_error != Error::FloatPrecisionLimitExceeded,
80 "LibXR::Format: float precision exceeds the configured print limit");
81 static_assert(result.compile_error != Error::UnexpectedEnd,
82 "LibXR::Format: unexpected end of format string");
84 result.compile_error != Error::EmbeddedNul,
85 "LibXR::Format: embedded NUL bytes are not supported in the format literal");
86 static_assert(result.compile_error != Error::UnmatchedBrace,
87 "LibXR::Format: unmatched brace in format string");
89 result.compile_error != Error::MixedIndexing,
90 "LibXR::Format: automatic and manual argument indexing cannot be mixed");
92 result.compile_error != Error::ManualIndexingDisabled,
93 "LibXR::Format: explicit argument indexing is disabled in the current profile");
94 static_assert(result.compile_error != Error::DynamicField,
95 "LibXR::Format: dynamic width and precision are not supported");
96 static_assert(result.compile_error != Error::InvalidArgumentIndex,
97 "LibXR::Format: invalid argument index");
98 static_assert(result.compile_error != Error::InvalidSpecifier,
99 "LibXR::Format: invalid format specifier");
100 static_assert(result.compile_error != Error::InvalidPresentation,
101 "LibXR::Format: invalid presentation type");
102 static_assert(result.compile_error != Error::MissingArgument,
103 "LibXR::Format: referenced argument index is out of range");
105 result.compile_error != Error::ArgumentTypeMismatch,
106 "LibXR::Format: format options are incompatible with the selected argument type");
107 static_assert(result.compile_error != Error::UnsupportedArgumentType,
108 "LibXR::Format: unsupported C++ argument type");
109 static_assert(result.compile_error != Error::TextOffsetOverflow,
110 "LibXR::Format: text pool offset is too large");
111 static_assert(result.compile_error != Error::TextSizeOverflow,
112 "LibXR::Format: text span is too large");
119 inline static constexpr auto codes = result.codes;
124 inline static constexpr Print::FormatProfile
profile = result.profile;
130 [[nodiscard]]
static constexpr auto ArgumentList() {
return result.arg_info; }
138 return source_analysis.argument_order;
145 [[nodiscard]]
static constexpr const auto&
Codes() {
return codes; }
151 [[nodiscard]]
static constexpr Print::FormatProfile
Profile() {
return profile; }
161 template <
typename... Actual>
164 return std::is_same_v<std::tuple<std::remove_cvref_t<Actual>...>,
165 std::tuple<Args...>>;
177 return source_analysis.required_argument_count;
187 template <
typename... Args>
190 if constexpr (
sizeof...(Args) != source_analysis.required_argument_count)
215 return Print::Writer::template RunArgumentOrder<Sink, Built, Built::ArgumentOrder()>(
216 sink, Built{}, std::forward<Args>(args)...);
221namespace LibXR::Print
234template <Text Source, OutputSink Sink,
typename... Args>
240 return Writer::template RunArgumentOrder<Sink, Built, Built::ArgumentOrder()>(
241 sink, Built{}, std::forward<Args>(args)...);
接收编译格式输出的写入端 / Output endpoint accepted by compiled format writers