8#include "format_frontend_detail.hpp"
13template <Pr
int::Text Source>
17 using SourceError = Print::Detail::FormatFrontend::Error;
18 inline static constexpr auto source_analysis =
19 Print::Detail::FormatFrontend::Analyze<Source>();
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");
25 static_assert(source_analysis.error != SourceError::EmbeddedNul,
26 "LibXR::Format: embedded NUL bytes are not supported in the format literal");
27 static_assert(source_analysis.error != SourceError::UnmatchedBrace,
28 "LibXR::Format: unmatched brace in format string");
29 static_assert(source_analysis.error != SourceError::MixedIndexing,
30 "LibXR::Format: automatic and manual argument indexing cannot be mixed");
31 static_assert(source_analysis.error != SourceError::ManualIndexingDisabled,
32 "LibXR::Format: explicit argument indexing is disabled in the current profile");
33 static_assert(source_analysis.error != SourceError::DynamicField,
34 "LibXR::Format: dynamic width and precision are not supported");
35 static_assert(source_analysis.error != SourceError::InvalidArgumentIndex,
36 "LibXR::Format: invalid argument index");
37 static_assert(source_analysis.error != SourceError::InvalidSpecifier,
38 "LibXR::Format: invalid format specifier");
39 static_assert(source_analysis.error != SourceError::InvalidPresentation,
40 "LibXR::Format: invalid presentation type");
47 using Error = Print::Detail::FormatFrontend::Error;
53 template <
typename... Args>
60 template <
typename... Args>
67 static_assert(source_analysis.error != SourceError::None ||
68 sizeof...(Args) == source_analysis.required_argument_count,
69 "LibXR::Format: call-site argument count does not match the "
70 "referenced replacement fields");
71 static_assert(result.compile_error != Error::NumberOverflow,
72 "LibXR::Format: index, width, or precision is too large");
73 static_assert(result.compile_error != Error::UnexpectedEnd,
74 "LibXR::Format: unexpected end of format string");
75 static_assert(result.compile_error != Error::EmbeddedNul,
76 "LibXR::Format: embedded NUL bytes are not supported in the format literal");
77 static_assert(result.compile_error != Error::UnmatchedBrace,
78 "LibXR::Format: unmatched brace in format string");
79 static_assert(result.compile_error != Error::MixedIndexing,
80 "LibXR::Format: automatic and manual argument indexing cannot be mixed");
81 static_assert(result.compile_error != Error::ManualIndexingDisabled,
82 "LibXR::Format: explicit argument indexing is disabled in the current profile");
83 static_assert(result.compile_error != Error::DynamicField,
84 "LibXR::Format: dynamic width and precision are not supported");
85 static_assert(result.compile_error != Error::InvalidArgumentIndex,
86 "LibXR::Format: invalid argument index");
87 static_assert(result.compile_error != Error::InvalidSpecifier,
88 "LibXR::Format: invalid format specifier");
89 static_assert(result.compile_error != Error::InvalidPresentation,
90 "LibXR::Format: invalid presentation type");
91 static_assert(result.compile_error != Error::MissingArgument,
92 "LibXR::Format: referenced argument index is out of range");
93 static_assert(result.compile_error != Error::ArgumentTypeMismatch,
94 "LibXR::Format: format options are incompatible with the selected argument type");
95 static_assert(result.compile_error != Error::UnsupportedArgumentType,
96 "LibXR::Format: unsupported C++ argument type");
97 static_assert(result.compile_error != Error::TextOffsetOverflow,
98 "LibXR::Format: text pool offset is too large");
99 static_assert(result.compile_error != Error::TextSizeOverflow,
100 "LibXR::Format: text span is too large");
104 inline static constexpr auto codes = result.codes;
106 inline static constexpr Print::FormatProfile
profile = result.profile;
111 return result.arg_info;
117 return source_analysis.argument_order;
121 [[nodiscard]]
static constexpr const auto&
Codes()
127 [[nodiscard]]
static constexpr Print::FormatProfile
Profile()
133 template <
typename... Actual>
136 return std::is_same_v<std::tuple<std::remove_cvref_t<Actual>...>,
137 std::tuple<Args...>>;
144 return source_analysis.required_argument_count;
148 template <
typename... Args>
151 if constexpr (
sizeof...(Args) != source_analysis.required_argument_count)
167 return Print::Writer::template RunArgumentOrder<Sink, Built, Built::ArgumentOrder()>(
168 sink, Built{}, std::forward<Args>(args)...);
173namespace LibXR::Print
180template <Text Source, OutputSink Sink,
typename... Args>
186 return Writer::template RunArgumentOrder<Sink, Built, Built::ArgumentOrder()>(
187 sink, Built{}, std::forward<Args>(args)...);