22template <
typename Char>
51 detail::locale_ref
locale() {
return {}; }
56 detail::error_handler().on_error(message);
66 unsigned max = max_value<int>();
75 value <= max_value<int>();
82 template <
typename T, FMT_ENABLE_IF(std::is_
integral<T>::value)>
89 template <
typename T, FMT_ENABLE_IF(!std::is_
integral<T>::value)>
99 template <
typename T, FMT_ENABLE_IF(std::is_
integral<T>::value)>
104 template <
typename T, FMT_ENABLE_IF(!std::is_
integral<T>::value)>
129 template <
typename U, FMT_ENABLE_IF(std::is_
integral<U>::value)>
133 if (
const_check(
sizeof(target_type) <=
sizeof(
int))) {
136 arg_ = detail::make_arg<Context>(
137 static_cast<int>(
static_cast<target_type
>(
value)));
140 arg_ = detail::make_arg<Context>(
141 static_cast<unsigned>(
static_cast<unsigned_type
>(
value)));
148 arg_ = detail::make_arg<Context>(
static_cast<long long>(
value));
150 arg_ = detail::make_arg<Context>(
156 template <
typename U, FMT_ENABLE_IF(!std::is_
integral<U>::value)>
164template <
typename T,
typename Context,
typename Char>
177 template <
typename T, FMT_ENABLE_IF(std::is_
integral<T>::value)>
179 arg_ = detail::make_arg<Context>(
180 static_cast<typename Context::char_type
>(
value));
183 template <
typename T, FMT_ENABLE_IF(!std::is_
integral<T>::value)>
190 template <
typename T>
const Char*
operator()(
T) {
return nullptr; }
205 template <
typename T, FMT_ENABLE_IF(std::is_
integral<T>::value)>
208 if (detail::is_negative(
value)) {
212 unsigned int_max = max_value<int>();
214 return static_cast<unsigned>(width);
217 template <
typename T, FMT_ENABLE_IF(!std::is_
integral<T>::value)>
225template <
typename OutputIt,
typename Char>
235 auto s = this->
specs;
246 template <
typename T, FMT_ENABLE_IF(detail::is_
integral<T>::value)>
252 if (fmt_specs.type && fmt_specs.type !=
'c')
253 return (*
this)(
static_cast<int>(
value));
255 fmt_specs.alt =
false;
256 fmt_specs.fill[0] =
' ';
261 return write<Char>(this->
out,
static_cast<Char
>(
value), fmt_specs);
266 template <
typename T, FMT_ENABLE_IF(std::is_
floating_po
int<T>::value)>
301template <
typename Char>
304 for (; it != end; ++it) {
329template <
typename Char,
typename GetArg>
334 if (c >=
'0' && c <=
'9') {
338 if (it != end && *it ==
'$') {
340 arg_index =
value != -1 ?
value : max_value<int>();
342 if (c ==
'0') specs.
fill[0] =
'0';
355 if (*it >=
'0' && *it <=
'9') {
358 }
else if (*it ==
'*') {
361 detail::printf_width_handler<Char>(specs),
get_arg(-1)));
367template <
typename Char,
typename Context>
371 auto out = OutputIt(buf);
377 auto get_arg = [&](
int arg_index) {
379 arg_index = parse_ctx.next_arg_id();
381 parse_ctx.check_arg_id(--arg_index);
382 return detail::get_arg(context, arg_index);
385 const Char* start = parse_ctx.begin();
386 const Char* end = parse_ctx.end();
389 if (!detail::find<false, Char>(it, end,
'%', it)) {
394 if (it != end && *it == c) {
401 start, detail::to_unsigned(it - 1 - start)));
408 if (arg_index == 0) parse_ctx.on_error(
"argument not found");
411 if (it != end && *it ==
'.') {
413 c = it != end ? *it : 0;
414 if (
'0' <= c && c <=
'9') {
416 }
else if (c ==
'*') {
431 if (specs.
precision >= 0 &&
arg.type() == detail::type::cstring_type) {
434 auto nul =
std::find(str, str_end, Char());
435 arg = detail::make_arg<basic_printf_context<OutputIt, Char>>(
437 str, detail::to_unsigned(nul != str_end ? nul - str
442 if (specs.
fill[0] ==
'0') {
451 c = it != end ? *it++ : 0;
452 Char t = it != end ? *it : 0;
453 using detail::convert_arg;
458 t = it != end ? *it : 0;
459 convert_arg<signed char>(
arg, t);
461 convert_arg<short>(
arg, t);
467 t = it != end ? *it : 0;
468 convert_arg<long long>(
arg, t);
470 convert_arg<long>(
arg, t);
474 convert_arg<intmax_t>(
arg, t);
477 convert_arg<size_t>(
arg, t);
480 convert_arg<std::ptrdiff_t>(
arg, t);
488 convert_arg<void>(
arg, c);
493 specs.
type =
static_cast<char>(*it++);
494 if (
arg.is_integral()) {
496 switch (specs.
type) {
513 detail::printf_arg_formatter<OutputIt, Char>(out, specs, context),
arg);
519template <
typename Char>
535template <
typename...
T>
547template <
typename...
T>
553template <
typename S,
typename Char =
char_t<S>>
572template <
typename S,
typename...
T,
573 typename Char = enable_if_t<detail::is_string<S>::value,
char_t<S>>>
576 return vsprintf(to_string_view(
fmt), fmt::make_format_args<context>(args...));
579template <
typename S,
typename Char =
char_t<S>>
589 :
static_cast<int>(size);
601template <
typename S,
typename...
T,
typename Char =
char_t<S>>
605 fmt::make_format_args<context>(args...));
608template <
typename S,
typename Char =
char_t<S>>
613 return vfprintf(stdout, to_string_view(
fmt), args);
625template <
typename S,
typename...
T,
FMT_ENABLE_IF(detail::is_string<S>::value)>
632template <
typename S,
typename Char =
char_t<S>>
642template <
typename S,
typename...
T,
typename Char =
char_t<S>>
644 const T&... args) ->
int {
arg_converter(basic_format_arg< Context > &arg, char_type type)
basic_format_arg< Context > & arg_
typename Context::char_type char_type
void operator()(bool value)
basic_format_args< basic_printf_context > args_
FMT_CONSTEXPR void on_error(const char *message)
format_arg arg(int id) const
detail::locale_ref locale()
basic_printf_context(OutputIt out, basic_format_args< basic_printf_context > args)
void advance_to(OutputIt it)
auto size() const FMT_NOEXCEPT -> size_t
auto data() FMT_NOEXCEPT -> T *
basic_format_arg< Context > & arg_
char_converter(basic_format_arg< Context > &arg)
basic_format_specs< Char > format_specs
printf_width_handler(format_specs &specs)
unsigned operator()(T value)
std::basic_string< Char > format(const text_style &ts, const S &format_str, const Args &... args)
FMT_CONSTEXPR FMT_INLINE auto visit_format_arg(Visitor &&vis, const basic_format_arg< Context > &arg) -> decltype(vis(0))
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
typename detail::char_t_impl< S >::type char_t
#define FMT_END_DETAIL_NAMESPACE
#define FMT_MODULE_EXPORT_BEGIN
#define FMT_BEGIN_NAMESPACE
#define FMT_BEGIN_DETAIL_NAMESPACE
constexpr auto const_check(T value) -> T
conditional_t< std::is_same< T, char >::value, appender, std::back_insert_iterator< buffer< T > > > buffer_appender
#define FMT_ENABLE_IF(...)
FMT_CONSTEXPR auto to_unsigned(Int value) -> typename std::make_unsigned< Int >::type
FMT_CONSTEXPR auto parse_nonnegative_int(const Char *&begin, const Char *end, int error_value) noexcept -> int
typename type_identity< T >::type type_identity_t
typename std::conditional< B, T, F >::type conditional_t
#define FMT_END_NAMESPACE
#define FMT_MODULE_EXPORT_END
auto write(OutputIt out, const std::tm &time, const std::locale &loc, char format, char modifier=0) -> OutputIt
void convert_arg(basic_format_arg< Context > &arg, Char type)
auto vfprintf(std::FILE *f, const S &fmt, basic_format_args< basic_printf_context_t< type_identity_t< Char > > > args) -> int
auto vsprintf(const S &fmt, basic_format_args< basic_printf_context_t< type_identity_t< Char > > > args) -> std::basic_string< Char >
auto make_wprintf_args(const T &... args) -> format_arg_store< wprintf_context, T... >
void vprintf(buffer< Char > &buf, basic_string_view< Char > format, basic_format_args< Context > args)
basic_printf_context_t< wchar_t > wprintf_context
auto fprintf(std::FILE *f, const S &fmt, const T &... args) -> int
auto printf(const S &fmt, const T &... args) -> int
auto sprintf(const S &fmt, const T &... args) -> std::basic_string< Char >
basic_printf_context_t< char > printf_context
void parse_flags(basic_format_specs< Char > &specs, const Char *&it, const Char *end)
auto make_printf_args(const T &... args) -> format_arg_store< printf_context, T... >
int parse_header(const Char *&it, const Char *end, basic_format_specs< Char > &specs, GetArg get_arg)
const Char * operator()(const Char *s)
const Char * operator()(T)
static bool fits_in_int(T value)
static bool fits_in_int(int)
static bool fits_in_int(bool)
static bool fits_in_int(T value)