WireCellToolkit
Wire Cell Simulation, Signal Process and Reconstruction Toolki for Liquid Argon Detectors
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
printf.h
Go to the documentation of this file.
1 // Formatting library for C++
2 //
3 // Copyright (c) 2012 - 2016, Victor Zverovich
4 // All rights reserved.
5 //
6 // For the license information refer to format.h.
7 
8 #ifndef FMT_PRINTF_H_
9 #define FMT_PRINTF_H_
10 
11 #include <algorithm> // std::fill_n
12 #include <limits> // std::numeric_limits
13 
14 #include "ostream.h"
15 
17 namespace internal {
18 
19 // An iterator that produces a null terminator on *end. This simplifies parsing
20 // and allows comparing the performance of processing a null-terminated string
21 // vs string_view.
22 template <typename Char>
23 class null_terminating_iterator {
24  public:
25  typedef std::ptrdiff_t difference_type;
26  typedef Char value_type;
27  typedef const Char* pointer;
28  typedef const Char& reference;
29  typedef std::random_access_iterator_tag iterator_category;
30 
31  null_terminating_iterator() : ptr_(0), end_(0) {}
32 
33  FMT_CONSTEXPR null_terminating_iterator(const Char *ptr, const Char *end)
34  : ptr_(ptr), end_(end) {}
35 
36  template <typename Range>
37  FMT_CONSTEXPR explicit null_terminating_iterator(const Range &r)
38  : ptr_(r.begin()), end_(r.end()) {}
39 
41  assert(ptr <= end_);
42  ptr_ = ptr;
43  return *this;
44  }
45 
46  FMT_CONSTEXPR Char operator*() const {
47  return ptr_ != end_ ? *ptr_ : Char();
48  }
49 
51  ++ptr_;
52  return *this;
53  }
54 
56  null_terminating_iterator result(*this);
57  ++ptr_;
58  return result;
59  }
60 
62  --ptr_;
63  return *this;
64  }
65 
67  return null_terminating_iterator(ptr_ + n, end_);
68  }
69 
71  return null_terminating_iterator(ptr_ - n, end_);
72  }
73 
75  ptr_ += n;
76  return *this;
77  }
78 
79  FMT_CONSTEXPR difference_type operator-(
80  null_terminating_iterator other) const {
81  return ptr_ - other.ptr_;
82  }
83 
85  return ptr_ != other.ptr_;
86  }
87 
89  return ptr_ >= other.ptr_;
90  }
91 
92  // This should be a friend specialization pointer_from<Char> but the latter
93  // doesn't compile by gcc 5.1 due to a compiler bug.
94  template <typename CharT>
95  friend FMT_CONSTEXPR_DECL const CharT *pointer_from(
97 
98  private:
99  const Char *ptr_;
100  const Char *end_;
101 };
102 
103 template <typename T>
104 FMT_CONSTEXPR const T *pointer_from(const T *p) { return p; }
105 
106 template <typename Char>
108  return it.ptr_;
109 }
110 
111 // DEPRECATED: Parses the input as an unsigned integer. This function assumes
112 // that the first character is a digit and presence of a non-digit character at
113 // the end.
114 // it: an iterator pointing to the beginning of the input range.
115 template <typename Iterator, typename ErrorHandler>
116 FMT_CONSTEXPR unsigned parse_nonnegative_int(Iterator &it, ErrorHandler &&eh) {
117  assert('0' <= *it && *it <= '9');
118  if (*it == '0') {
119  ++it;
120  return 0;
121  }
122  unsigned value = 0;
123  // Convert to unsigned to prevent a warning.
124  unsigned max_int = (std::numeric_limits<int>::max)();
125  unsigned big = max_int / 10;
126  do {
127  // Check for overflow.
128  if (value > big) {
129  value = max_int + 1;
130  break;
131  }
132  value = value * 10 + unsigned(*it - '0');
133  // Workaround for MSVC "setup_exception stack overflow" error:
134  auto next = it;
135  ++next;
136  it = next;
137  } while ('0' <= *it && *it <= '9');
138  if (value > max_int)
139  eh.on_error("number is too big");
140  return value;
141 }
142 
143 // Checks if a value fits in int - used to avoid warnings about comparing
144 // signed and unsigned integers.
145 template <bool IsSigned>
146 struct int_checker {
147  template <typename T>
148  static bool fits_in_int(T value) {
149  unsigned max = std::numeric_limits<int>::max();
150  return value <= max;
151  }
152  static bool fits_in_int(bool) { return true; }
153 };
154 
155 template <>
156 struct int_checker<true> {
157  template <typename T>
158  static bool fits_in_int(T value) {
159  return value >= std::numeric_limits<int>::min() &&
161  }
162  static bool fits_in_int(int) { return true; }
163 };
164 
165 class printf_precision_handler: public function<int> {
166  public:
167  template <typename T>
168  typename std::enable_if<std::is_integral<T>::value, int>::type
170  if (!int_checker<std::numeric_limits<T>::is_signed>::fits_in_int(value))
171  FMT_THROW(format_error("number is too big"));
172  return static_cast<int>(value);
173  }
174 
175  template <typename T>
176  typename std::enable_if<!std::is_integral<T>::value, int>::type operator()(T) {
177  FMT_THROW(format_error("precision is not integer"));
178  return 0;
179  }
180 };
181 
182 // An argument visitor that returns true iff arg is a zero integer.
183 class is_zero_int: public function<bool> {
184  public:
185  template <typename T>
186  typename std::enable_if<std::is_integral<T>::value, bool>::type
187  operator()(T value) { return value == 0; }
188 
189  template <typename T>
190  typename std::enable_if<!std::is_integral<T>::value, bool>::type
191  operator()(T) { return false; }
192 };
193 
194 template <typename T>
195 struct make_unsigned_or_bool : std::make_unsigned<T> {};
196 
197 template <>
198 struct make_unsigned_or_bool<bool> {
199  typedef bool type;
200 };
201 
202 template <typename T, typename Context>
203 class arg_converter: public function<void> {
204  private:
205  typedef typename Context::char_type Char;
206 
208  typename Context::char_type type_;
209 
210  public:
212  : arg_(arg), type_(type) {}
213 
214  void operator()(bool value) {
215  if (type_ != 's')
216  operator()<bool>(value);
217  }
218 
219  template <typename U>
220  typename std::enable_if<std::is_integral<U>::value>::type
222  bool is_signed = type_ == 'd' || type_ == 'i';
223  typedef typename std::conditional<
224  std::is_same<T, void>::value, U, T>::type TargetType;
225  if (const_check(sizeof(TargetType) <= sizeof(int))) {
226  // Extra casts are used to silence warnings.
227  if (is_signed) {
228  arg_ = internal::make_arg<Context>(
229  static_cast<int>(static_cast<TargetType>(value)));
230  } else {
231  typedef typename make_unsigned_or_bool<TargetType>::type Unsigned;
232  arg_ = internal::make_arg<Context>(
233  static_cast<unsigned>(static_cast<Unsigned>(value)));
234  }
235  } else {
236  if (is_signed) {
237  // glibc's printf doesn't sign extend arguments of smaller types:
238  // std::printf("%lld", -42); // prints "4294967254"
239  // but we don't have to do the same because it's a UB.
240  arg_ = internal::make_arg<Context>(static_cast<long long>(value));
241  } else {
242  arg_ = internal::make_arg<Context>(
243  static_cast<typename make_unsigned_or_bool<U>::type>(value));
244  }
245  }
246  }
247 
248  template <typename U>
249  typename std::enable_if<!std::is_integral<U>::value>::type operator()(U) {
250  // No coversion needed for non-integral types.
251  }
252 };
253 
254 // Converts an integer argument to T for printf, if T is an integral type.
255 // If T is void, the argument is converted to corresponding signed or unsigned
256 // type depending on the type specifier: 'd' and 'i' - signed, other -
257 // unsigned).
258 template <typename T, typename Context, typename Char>
261 }
262 
263 // Converts an integer argument to char for printf.
264 template <typename Context>
265 class char_converter: public function<void> {
266  private:
268 
269  public:
270  explicit char_converter(basic_format_arg<Context> &arg) : arg_(arg) {}
271 
272  template <typename T>
273  typename std::enable_if<std::is_integral<T>::value>::type
275  typedef typename Context::char_type Char;
276  arg_ = internal::make_arg<Context>(static_cast<Char>(value));
277  }
278 
279  template <typename T>
280  typename std::enable_if<!std::is_integral<T>::value>::type operator()(T) {
281  // No coversion needed for non-integral types.
282  }
283 };
284 
285 // Checks if an argument is a valid printf width specifier and sets
286 // left alignment if it is negative.
287 template <typename Char>
288 class printf_width_handler: public function<unsigned> {
289  private:
291 
292  format_specs &spec_;
293 
294  public:
295  explicit printf_width_handler(format_specs &spec) : spec_(spec) {}
296 
297  template <typename T>
298  typename std::enable_if<std::is_integral<T>::value, unsigned>::type
300  typedef typename internal::int_traits<T>::main_type UnsignedType;
301  UnsignedType width = static_cast<UnsignedType>(value);
302  if (internal::is_negative(value)) {
303  spec_.align_ = ALIGN_LEFT;
304  width = 0 - width;
305  }
306  unsigned int_max = std::numeric_limits<int>::max();
307  if (width > int_max)
308  FMT_THROW(format_error("number is too big"));
309  return static_cast<unsigned>(width);
310  }
311 
312  template <typename T>
313  typename std::enable_if<!std::is_integral<T>::value, unsigned>::type
315  FMT_THROW(format_error("width is not integer"));
316  return 0;
317  }
318 };
319 
320 template <typename Char, typename Context>
323  Context(std::back_inserter(buf), format, args).format();
324 }
325 } // namespace internal
326 
327 using internal::printf; // For printing into memory_buffer.
328 
329 template <typename Range>
331 
332 template <
333  typename OutputIt, typename Char,
334  typename ArgFormatter =
337 
343 template <typename Range>
345  public internal::function<
346  typename internal::arg_formatter_base<Range>::iterator>,
347  public internal::arg_formatter_base<Range> {
348  private:
349  typedef typename Range::value_type char_type;
350  typedef decltype(internal::declval<Range>().begin()) iterator;
351  typedef internal::arg_formatter_base<Range> base;
352  typedef basic_printf_context<iterator, char_type> context_type;
353 
354  context_type &context_;
355 
356  void write_null_pointer(char) {
357  this->spec()->type = 0;
358  this->write("(nil)");
359  }
360 
361  void write_null_pointer(wchar_t) {
362  this->spec()->type = 0;
363  this->write(L"(nil)");
364  }
365 
366  public:
368 
377  format_specs &spec, context_type &ctx)
378  : base(back_insert_range<internal::basic_buffer<char_type>>(buffer), &spec,
379  ctx.locale()),
380  context_(ctx) {}
381 
382  template <typename T>
383  typename std::enable_if<std::is_integral<T>::value, iterator>::type
384  operator()(T value) {
385  // MSVC2013 fails to compile separate overloads for bool and char_type so
386  // use std::is_same instead.
387  if (std::is_same<T, bool>::value) {
388  format_specs &fmt_spec = *this->spec();
389  if (fmt_spec.type != 's')
390  return base::operator()(value ? 1 : 0);
391  fmt_spec.type = 0;
392  this->write(value != 0);
393  } else if (std::is_same<T, char_type>::value) {
394  format_specs &fmt_spec = *this->spec();
395  if (fmt_spec.type && fmt_spec.type != 'c')
396  return (*this)(static_cast<int>(value));
397  fmt_spec.flags = 0;
398  fmt_spec.align_ = ALIGN_RIGHT;
399  return base::operator()(value);
400  } else {
401  return base::operator()(value);
402  }
403  return this->out();
404  }
405 
406  template <typename T>
407  typename std::enable_if<std::is_floating_point<T>::value, iterator>::type
408  operator()(T value) {
409  return base::operator()(value);
410  }
411 
413  iterator operator()(const char *value) {
414  if (value)
415  base::operator()(value);
416  else if (this->spec()->type == 'p')
417  write_null_pointer(char_type());
418  else
419  this->write("(null)");
420  return this->out();
421  }
422 
424  iterator operator()(const wchar_t *value) {
425  if (value)
426  base::operator()(value);
427  else if (this->spec()->type == 'p')
428  write_null_pointer(char_type());
429  else
430  this->write(L"(null)");
431  return this->out();
432  }
433 
435  return base::operator()(value);
436  }
437 
438  iterator operator()(monostate value) {
439  return base::operator()(value);
440  }
441 
443  iterator operator()(const void *value) {
444  if (value)
445  return base::operator()(value);
446  this->spec()->type = 0;
447  write_null_pointer(char_type());
448  return this->out();
449  }
450 
453  handle.format(context_);
454  return this->out();
455  }
456 };
457 
458 template <typename T>
460  template <typename ParseContext>
461  auto parse(ParseContext &ctx) -> decltype(ctx.begin()) { return ctx.begin(); }
462 
463  template <typename FormatContext>
464  auto format(const T &value, FormatContext &ctx) -> decltype(ctx.out()) {
466  return ctx.out();
467  }
468 };
469 
471 template <typename OutputIt, typename Char, typename ArgFormatter>
472 class basic_printf_context :
473  // Inherit publicly as a workaround for the icc bug
474  // https://software.intel.com/en-us/forums/intel-c-compiler/topic/783476.
475  public internal::context_base<
476  OutputIt, basic_printf_context<OutputIt, Char, ArgFormatter>, Char> {
477  public:
479  typedef Char char_type;
480 
481  template <typename T>
483 
484  private:
486  typedef typename base::format_arg format_arg;
489 
490  void parse_flags(format_specs &spec, iterator &it);
491 
492  // Returns the argument with specified index or, if arg_index is equal
493  // to the maximum unsigned value, the next argument.
494  format_arg get_arg(
495  iterator it,
496  unsigned arg_index = (std::numeric_limits<unsigned>::max)());
497 
498  // Parses argument index, flags and width and returns the argument index.
499  unsigned parse_header(iterator &it, format_specs &spec);
500 
501  public:
511  : base(out, format_str, args) {}
512 
513  using base::parse_context;
514  using base::out;
515  using base::advance_to;
516 
518  void format();
519 };
520 
521 template <typename OutputIt, typename Char, typename AF>
523  format_specs &spec, iterator &it) {
524  for (;;) {
525  switch (*it++) {
526  case '-':
527  spec.align_ = ALIGN_LEFT;
528  break;
529  case '+':
530  spec.flags |= SIGN_FLAG | PLUS_FLAG;
531  break;
532  case '0':
533  spec.fill_ = '0';
534  break;
535  case ' ':
536  spec.flags |= SIGN_FLAG;
537  break;
538  case '#':
539  spec.flags |= HASH_FLAG;
540  break;
541  default:
542  --it;
543  return;
544  }
545  }
546 }
547 
548 template <typename OutputIt, typename Char, typename AF>
551  iterator it, unsigned arg_index) {
552  (void)it;
553  if (arg_index == std::numeric_limits<unsigned>::max())
554  return this->do_get_arg(this->parse_context().next_arg_id());
555  return base::get_arg(arg_index - 1);
556 }
557 
558 template <typename OutputIt, typename Char, typename AF>
560  iterator &it, format_specs &spec) {
561  unsigned arg_index = std::numeric_limits<unsigned>::max();
562  char_type c = *it;
563  if (c >= '0' && c <= '9') {
564  // Parse an argument index (if followed by '$') or a width possibly
565  // preceded with '0' flag(s).
567  unsigned value = parse_nonnegative_int(it, eh);
568  if (*it == '$') { // value is an argument index
569  ++it;
570  arg_index = value;
571  } else {
572  if (c == '0')
573  spec.fill_ = '0';
574  if (value != 0) {
575  // Nonzero value means that we parsed width and don't need to
576  // parse it or flags again, so return now.
577  spec.width_ = value;
578  return arg_index;
579  }
580  }
581  }
582  parse_flags(spec, it);
583  // Parse width.
584  if (*it >= '0' && *it <= '9') {
586  spec.width_ = parse_nonnegative_int(it, eh);
587  } else if (*it == '*') {
588  ++it;
589  spec.width_ = visit_format_arg(
590  internal::printf_width_handler<char_type>(spec), get_arg(it));
591  }
592  return arg_index;
593 }
594 
595 template <typename OutputIt, typename Char, typename AF>
597  auto &buffer = internal::get_container(this->out());
598  auto start = iterator(this->parse_context());
599  auto it = start;
601  while (*it) {
602  char_type c = *it++;
603  if (c != '%') continue;
604  if (*it == c) {
605  buffer.append(pointer_from(start), pointer_from(it));
606  start = ++it;
607  continue;
608  }
609  buffer.append(pointer_from(start), pointer_from(it) - 1);
610 
611  format_specs spec;
612  spec.align_ = ALIGN_RIGHT;
613 
614  // Parse argument index, flags and width.
615  unsigned arg_index = parse_header(it, spec);
616 
617  // Parse precision.
618  if (*it == '.') {
619  ++it;
620  if ('0' <= *it && *it <= '9') {
622  spec.precision = static_cast<int>(parse_nonnegative_int(it, eh));
623  } else if (*it == '*') {
624  ++it;
625  spec.precision =
627  } else {
628  spec.precision = 0;
629  }
630  }
631 
632  format_arg arg = get_arg(it, arg_index);
634  spec.flags = static_cast<uint_least8_t>(spec.flags & (~internal::to_unsigned<int>(HASH_FLAG)));
635  if (spec.fill_ == '0') {
636  if (arg.is_arithmetic())
637  spec.align_ = ALIGN_NUMERIC;
638  else
639  spec.fill_ = ' '; // Ignore '0' flag for non-numeric types.
640  }
641 
642  // Parse length and convert the argument to the required type.
643  using internal::convert_arg;
644  switch (*it++) {
645  case 'h':
646  if (*it == 'h')
647  convert_arg<signed char>(arg, *++it);
648  else
649  convert_arg<short>(arg, *it);
650  break;
651  case 'l':
652  if (*it == 'l')
653  convert_arg<long long>(arg, *++it);
654  else
655  convert_arg<long>(arg, *it);
656  break;
657  case 'j':
658  convert_arg<intmax_t>(arg, *it);
659  break;
660  case 'z':
661  convert_arg<std::size_t>(arg, *it);
662  break;
663  case 't':
664  convert_arg<std::ptrdiff_t>(arg, *it);
665  break;
666  case 'L':
667  // printf produces garbage when 'L' is omitted for long double, no
668  // need to do the same.
669  break;
670  default:
671  --it;
672  convert_arg<void>(arg, *it);
673  }
674 
675  // Parse type.
676  if (!*it)
677  FMT_THROW(format_error("invalid format string"));
678  spec.type = static_cast<char>(*it++);
679  if (arg.is_integral()) {
680  // Normalize type.
681  switch (spec.type) {
682  case 'i': case 'u':
683  spec.type = 'd';
684  break;
685  case 'c':
686  // TODO: handle wchar_t better?
689  break;
690  }
691  }
692 
693  start = it;
694 
695  // Format argument.
696  visit_format_arg(AF(buffer, spec, *this), arg);
697  }
698  buffer.append(pointer_from(start), pointer_from(it));
699 }
700 
701 template <typename Buffer>
703  typedef basic_printf_context<
704  std::back_insert_iterator<Buffer>, typename Buffer::value_type> type;
705 };
706 
709 
712 
719 template<typename... Args>
720 inline format_arg_store<printf_context, Args...>
721  make_printf_args(const Args &... args) { return {args...}; }
722 
729 template<typename... Args>
730 inline format_arg_store<wprintf_context, Args...>
731  make_wprintf_args(const Args &... args) { return {args...}; }
732 
733 template <typename S, typename Char = FMT_CHAR(S)>
734 inline std::basic_string<Char>
735 vsprintf(const S &format,
739  printf(buffer, to_string_view(format), args);
740  return to_string(buffer);
741 }
742 
752 template <typename S, typename... Args>
753 inline FMT_ENABLE_IF_T(
754  internal::is_string<S>::value, std::basic_string<FMT_CHAR(S)>)
755  sprintf(const S &format, const Args & ... args) {
759  format_arg_store<context, Args...> as{ args... };
760  return vsprintf(to_string_view(format),
762 }
763 
764 template <typename S, typename Char = FMT_CHAR(S)>
765 inline int vfprintf(std::FILE *f, const S &format,
769  printf(buffer, to_string_view(format), args);
770  std::size_t size = buffer.size();
771  return std::fwrite(
772  buffer.data(), sizeof(Char), size, f) < size ? -1 : static_cast<int>(size);
773 }
774 
784 template <typename S, typename... Args>
786  fprintf(std::FILE *f, const S &format, const Args & ... args) {
790  format_arg_store<context, Args...> as{ args... };
791  return vfprintf(f, to_string_view(format),
793 }
794 
795 template <typename S, typename Char = FMT_CHAR(S)>
796 inline int vprintf(const S &format,
799  return vfprintf(stdout, to_string_view(format), args);
800 }
801 
811 template <typename S, typename... Args>
813  printf(const S &format_str, const Args & ... args) {
817  format_arg_store<context, Args...> as{ args... };
818  return vprintf(to_string_view(format_str),
820 }
821 
822 template <typename S, typename Char = FMT_CHAR(S)>
823 inline int vfprintf(std::basic_ostream<Char> &os,
824  const S &format,
828  printf(buffer, to_string_view(format), args);
829  internal::write(os, buffer);
830  return static_cast<int>(buffer.size());
831 }
832 
842 template <typename S, typename... Args>
844  fprintf(std::basic_ostream<FMT_CHAR(S)> &os,
845  const S &format_str, const Args & ... args) {
849  format_arg_store<context, Args...> as{ args... };
850  return vfprintf(os, to_string_view(format_str),
852 }
854 
855 #endif // FMT_PRINTF_H_
printf_formatter< T > type
Definition: printf.h:482
FMT_CONSTEXPR null_terminating_iterator operator--()
Definition: printf.h:61
void format(Context &ctx) const
Definition: core.h:802
std::enable_if<!std::is_integral< T >::value, bool >::type operator()(T)
Definition: printf.h:191
wchar_t fill_
Definition: format.h:1091
Container & get_container(std::back_insert_iterator< Container > it)
Definition: core.h:313
FMT_CONSTEXPR null_terminating_iterator(const Range &r)
Definition: printf.h:37
FMT_CONSTEXPR_DECL const Char * pointer_from(null_terminating_iterator< Char > it)
Definition: printf.h:107
static bool fits_in_int(int)
Definition: printf.h:162
alignment align_
Definition: format.h:1092
std::enable_if< std::is_integral< U >::value >::type operator()(U value)
Definition: printf.h:221
iterator operator()(monostate value)
Definition: printf.h:438
basic_printf_context_t< internal::wbuffer >::type wprintf_context
Definition: printf.h:708
bool is_integral() const
Definition: core.h:816
basic_printf_context_t< internal::buffer >::type printf_context
Definition: printf.h:707
FMT_CONSTEXPR auto begin(const C &c) -> decltype(c.begin())
Definition: format.h:251
basic_format_args< printf_context > printf_args
Definition: printf.h:710
char_converter(basic_format_arg< Context > &arg)
Definition: printf.h:270
internal::named_arg< T, char > arg(string_view name, const T &arg)
Definition: core.h:1391
bool is_arithmetic() const
Definition: core.h:817
void append(const U *begin, const U *end)
Definition: format.h:394
FMT_CONSTEXPR null_terminating_iterator operator++(int)
Definition: printf.h:55
const S & format_str
Definition: format.h:3342
FMT_CONSTEXPR difference_type operator-(null_terminating_iterator other) const
Definition: printf.h:79
#define FMT_CONSTEXPR_DECL
Definition: core.h:70
static bool fits_in_int(T value)
Definition: printf.h:158
basic_printf_context< std::back_insert_iterator< Buffer >, typename Buffer::value_type > type
Definition: printf.h:704
void printf(basic_buffer< Char > &buf, basic_string_view< Char > format, basic_format_args< Context > args)
Definition: printf.h:321
FMT_CONSTEXPR bool operator!=(null_terminating_iterator other) const
Definition: printf.h:84
void write(std::basic_ostream< Char > &os, basic_buffer< Char > &buf)
Definition: ostream.h:76
FMT_CONSTEXPR null_terminating_iterator operator-(difference_type n)
Definition: printf.h:70
FMT_CONSTEXPR null_terminating_iterator(const Char *ptr, const Char *end)
Definition: printf.h:33
basic_format_specs< char > format_specs
Definition: format.h:1115
iterator operator()(const char *value)
Definition: printf.h:413
#define FMT_END_NAMESPACE
Definition: core.h:153
basic_printf_context_t< buffer >::type context
Definition: printf.h:758
#define FMT_THROW(x)
Definition: format.h:115
std::enable_if<!is_compile_string< S >::value >::type check_format_string(const S &)
Definition: core.h:1352
std::basic_string< FMT_CHAR(S)> format(const S &format_str, const Args &... args)
Definition: core.h:1454
T * data() FMT_NOEXCEPT
Definition: core.h:256
std::enable_if<!std::is_integral< U >::value >::type operator()(U)
Definition: printf.h:249
FMT_CONSTEXPR auto end(const C &c) -> decltype(c.end())
Definition: format.h:257
dummy_string_view to_string_view(...)
typedef FMT_CHAR(S) Char
auto parse(ParseContext &ctx) -> decltype(ctx.begin())
Definition: printf.h:461
friend FMT_CONSTEXPR_DECL const CharT * pointer_from(null_terminating_iterator< CharT > it)
FMT_CONSTEXPR Char operator*() const
Definition: printf.h:46
std::size_t size() const FMT_NOEXCEPT
Definition: core.h:250
auto format(const T &value, FormatContext &ctx) -> decltype(ctx.out())
Definition: printf.h:464
static bool fits_in_int(T value)
Definition: printf.h:148
iterator operator()(basic_string_view< char_type > value)
Definition: printf.h:434
void operator()(bool value)
Definition: printf.h:214
iterator operator()(const wchar_t *value)
Definition: printf.h:424
basic_buffer< char > buffer
Definition: core.h:291
std::enable_if<!std::is_integral< T >::value, int >::type operator()(T)
Definition: printf.h:176
std::random_access_iterator_tag iterator_category
Definition: printf.h:29
iterator operator()(typename basic_format_arg< context_type >::handle handle)
Definition: printf.h:452
printf_arg_formatter(internal::basic_buffer< char_type > &buffer, format_specs &spec, context_type &ctx)
Definition: printf.h:376
FMT_CONSTEXPR null_terminating_iterator & operator=(const Char *ptr)
Definition: printf.h:40
format_arg_store< printf_context, Args... > make_printf_args(const Args &... args)
Definition: printf.h:721
int vprintf(const S &format, basic_format_args< typename basic_printf_context_t< internal::basic_buffer< Char >>::type > args)
Definition: printf.h:796
std::basic_string< Char > vsprintf(const S &format, basic_format_args< typename basic_printf_context_t< internal::basic_buffer< Char >>::type > args)
Definition: printf.h:735
int vfprintf(std::FILE *f, const S &format, basic_format_args< typename basic_printf_context_t< internal::basic_buffer< Char >>::type > args)
Definition: printf.h:765
FMT_CONSTEXPR std::enable_if< std::numeric_limits< T >::is_signed, bool >::type is_negative(T value)
Definition: format.h:727
std::string to_string(const T &value)
Definition: format.h:3209
iterator operator()(const void *value)
Definition: printf.h:443
uint_least8_t flags
Definition: format.h:1102
std::enable_if<!std::is_integral< T >::value, unsigned >::type operator()(T)
Definition: printf.h:314
#define FMT_CONSTEXPR
Definition: core.h:69
format_arg_store< wprintf_context, Args... > make_wprintf_args(const Args &... args)
Definition: printf.h:731
const void * ptr(const T *p)
Definition: format.h:3138
FMT_CONSTEXPR null_terminating_iterator operator+=(difference_type n)
Definition: printf.h:74
basic_format_args< wprintf_context > wprintf_args
Definition: printf.h:711
static bool fits_in_int(bool)
Definition: printf.h:152
FMT_CONSTEXPR unsigned parse_nonnegative_int(const Char *&begin, const Char *end, ErrorHandler &&eh)
Definition: format.h:1454
std::enable_if< std::is_integral< T >::value, bool >::type operator()(T value)
Definition: printf.h:187
FMT_ENABLE_IF_T(internal::is_string< S >::value, std::basic_string< FMT_CHAR(S)>) sprintf(const S &format
std::enable_if< std::is_integral< T >::value >::type operator()(T value)
Definition: printf.h:274
FMT_CONSTEXPR bool has(unsigned f) const
Definition: format.h:1106
const Args & args
Definition: printf.h:755
std::enable_if< std::is_integral< T >::value, int >::type operator()(T value)
Definition: printf.h:169
format_arg_store< context, Args... > as
Definition: printf.h:759
T const_check(T value)
Definition: format.h:293
void format_value(basic_buffer< Char > &buffer, const T &value)
Definition: ostream.h:91
std::enable_if<!std::is_integral< T >::value >::type operator()(T)
Definition: printf.h:280
std::enable_if< std::is_integral< T >::value, unsigned >::type operator()(T value)
Definition: printf.h:299
basic_printf_context(OutputIt out, basic_string_view< char_type > format_str, basic_format_args< basic_printf_context > args)
Definition: printf.h:509
unsigned width_
Definition: format.h:1088
bool operator>=(null_terminating_iterator other) const
Definition: printf.h:88
std::enable_if< std::is_floating_point< T >::value, iterator >::type operator()(T value)
Definition: printf.h:408
std::size_t n
Definition: format.h:3399
void convert_arg(basic_format_arg< Context > &arg, Char type)
Definition: printf.h:259
basic_parse_context< char > parse_context
Definition: core.h:929
std::ptrdiff_t difference_type
Definition: printf.h:25
FMT_CONSTEXPR null_terminating_iterator operator+(difference_type n)
Definition: printf.h:66
arg_converter(basic_format_arg< Context > &arg, Char type)
Definition: printf.h:211
FMT_CONSTEXPR internal::result_of< Visitor(int)>::type visit_format_arg(Visitor &&vis, const basic_format_arg< Context > &arg)
Definition: core.h:831
FMT_CONSTEXPR null_terminating_iterator operator++()
Definition: printf.h:50
printf_width_handler(format_specs &spec)
Definition: printf.h:295
std::enable_if< std::is_integral< T >::value, iterator >::type operator()(T value)
Definition: printf.h:384
type
Definition: core.h:530
base::format_specs format_specs
Definition: printf.h:367