| 1849 | // Data for write_int that doesn't depend on output iterator type. It is used to |
| 1850 | // avoid template code bloat. |
| 1851 | template <typename Char> struct write_int_data { |
| 1852 | size_t size; |
| 1853 | size_t padding; |
| 1854 | |
| 1855 | FMT_CONSTEXPR write_int_data(int num_digits, unsigned prefix, |
| 1856 | const basic_format_specs<Char>& specs) |
| 1857 | : size((prefix >> 24) + to_unsigned(num_digits)), padding(0) { |
| 1858 | if (specs.align == align::numeric) { |
| 1859 | auto width = to_unsigned(specs.width); |
| 1860 | if (width > size) { |
| 1861 | padding = width - size; |
| 1862 | size = width; |
| 1863 | } |
| 1864 | } else if (specs.precision > num_digits) { |
| 1865 | size = (prefix >> 24) + to_unsigned(specs.precision); |
| 1866 | padding = to_unsigned(specs.precision - num_digits); |
| 1867 | } |
| 1868 | } |
| 1869 | }; |
| 1870 | |
| 1871 | // Writes an integer in the format |
| 1872 | // <left-padding><prefix><numeric-padding><digits><right-padding> |
| 1873 | // where <digits> are written by write_digits(it). |
| 1874 | // prefix contains chars in three lower bytes and the size in the fourth byte. |
| 1875 | template <typename OutputIt, typename Char, typename W> |
| 1876 | FMT_CONSTEXPR FMT_INLINE auto write_int(OutputIt out, int num_digits, |
| 1877 | unsigned prefix, |
| 1878 | const basic_format_specs<Char>& specs, |
| 1879 | W write_digits) -> OutputIt { |
| 1880 | // Slightly faster check for specs.width == 0 && specs.precision == -1. |
| 1881 | if ((specs.width | (specs.precision + 1)) == 0) { |
| 1882 | auto it = reserve(out, to_unsigned(num_digits) + (prefix >> 24)); |
| 1883 | if (prefix != 0) { |
| 1884 | for (unsigned p = prefix & 0xffffff; p != 0; p >>= 8) |
| 1885 | *it++ = static_cast<Char>(p & 0xff); |
| 1886 | } |
| 1887 | return base_iterator(out, write_digits(it)); |
| 1888 | } |
| 1889 | auto data = write_int_data<Char>(num_digits, prefix, specs); |
| 1890 | return write_padded<align::right>( |
| 1891 | out, specs, data.size, [=](reserve_iterator<OutputIt> it) { |
| 1892 | for (unsigned p = prefix & 0xffffff; p != 0; p >>= 8) |
| 1893 | *it++ = static_cast<Char>(p & 0xff); |
| 1894 | it = detail::fill_n(it, data.padding, static_cast<Char>('0')); |
| 1895 | return write_digits(it); |
| 1896 | }); |
| 1897 | } |
| 1898 | |
| 1899 | template <typename Char> class digit_grouping { |
| 1900 | private: |
| 1901 | thousands_sep_result<Char> sep_; |
| 1902 | |
| 1903 | struct next_state { |
| 1904 | #if FMT_USE_LOCALE_GROUPING |
| 1905 | std::string::const_iterator group; |
| 1906 | #endif |
| 1907 | int pos; |
| 1908 | }; |
nothing calls this directly
no test coverage detected