mirror of
https://github.com/fmtlib/fmt.git
synced 2026-04-29 18:23:24 +02:00
Produce a compile error when using wide fill character on a narrow stream.
This commit is contained in:
@@ -170,7 +170,7 @@ void fmt::BasicWriter<Char>::FormatDecimal(
|
||||
template <typename Char>
|
||||
typename fmt::BasicWriter<Char>::CharPtr
|
||||
fmt::BasicWriter<Char>::PrepareFilledBuffer(
|
||||
unsigned size, const AlignSpec &spec, char sign) {
|
||||
unsigned size, const AlignSpec<Char> &spec, char sign) {
|
||||
unsigned width = spec.width();
|
||||
if (width <= size) {
|
||||
CharPtr p = GrowBuffer(size);
|
||||
@@ -180,6 +180,7 @@ typename fmt::BasicWriter<Char>::CharPtr
|
||||
CharPtr p = GrowBuffer(width);
|
||||
CharPtr end = p + width;
|
||||
Alignment align = spec.align();
|
||||
// TODO: error if fill is not convertible to Char
|
||||
Char fill = static_cast<Char>(spec.fill());
|
||||
if (align == ALIGN_LEFT) {
|
||||
*p = sign;
|
||||
@@ -207,7 +208,7 @@ typename fmt::BasicWriter<Char>::CharPtr
|
||||
template <typename Char>
|
||||
template <typename T>
|
||||
void fmt::BasicWriter<Char>::FormatDouble(
|
||||
T value, const FormatSpec &spec, int precision) {
|
||||
T value, const FormatSpec<Char> &spec, int precision) {
|
||||
// Check type.
|
||||
char type = spec.type();
|
||||
bool upper = false;
|
||||
@@ -437,7 +438,7 @@ void fmt::BasicFormatter<Char>::DoFormat() {
|
||||
|
||||
const Arg &arg = ParseArgIndex(s);
|
||||
|
||||
FormatSpec spec;
|
||||
FormatSpec<Char> spec;
|
||||
int precision = -1;
|
||||
if (*s == ':') {
|
||||
++s;
|
||||
@@ -665,10 +666,10 @@ void fmt::BasicFormatter<Char>::DoFormat() {
|
||||
// Explicit instantiations for char.
|
||||
|
||||
template void fmt::BasicWriter<char>::FormatDouble<double>(
|
||||
double value, const FormatSpec &spec, int precision);
|
||||
double value, const FormatSpec<char> &spec, int precision);
|
||||
|
||||
template void fmt::BasicWriter<char>::FormatDouble<long double>(
|
||||
long double value, const FormatSpec &spec, int precision);
|
||||
long double value, const FormatSpec<char> &spec, int precision);
|
||||
|
||||
template fmt::BasicWriter<char>::CharPtr
|
||||
fmt::BasicWriter<char>::FillPadding(CharPtr buffer,
|
||||
@@ -679,7 +680,7 @@ template void fmt::BasicWriter<char>::FormatDecimal(
|
||||
|
||||
template fmt::BasicWriter<char>::CharPtr
|
||||
fmt::BasicWriter<char>::PrepareFilledBuffer(
|
||||
unsigned size, const AlignSpec &spec, char sign);
|
||||
unsigned size, const AlignSpec<char> &spec, char sign);
|
||||
|
||||
template void fmt::BasicFormatter<char>::ReportError(
|
||||
const char *s, StringRef message) const;
|
||||
@@ -697,10 +698,10 @@ template void fmt::BasicFormatter<char>::DoFormat();
|
||||
// Explicit instantiations for wchar_t.
|
||||
|
||||
template void fmt::BasicWriter<wchar_t>::FormatDouble<double>(
|
||||
double value, const FormatSpec &spec, int precision);
|
||||
double value, const FormatSpec<wchar_t> &spec, int precision);
|
||||
|
||||
template void fmt::BasicWriter<wchar_t>::FormatDouble<long double>(
|
||||
long double value, const FormatSpec &spec, int precision);
|
||||
long double value, const FormatSpec<wchar_t> &spec, int precision);
|
||||
|
||||
template fmt::BasicWriter<wchar_t>::CharPtr
|
||||
fmt::BasicWriter<wchar_t>::FillPadding(CharPtr buffer,
|
||||
@@ -711,7 +712,7 @@ template void fmt::BasicWriter<wchar_t>::FormatDecimal(
|
||||
|
||||
template fmt::BasicWriter<wchar_t>::CharPtr
|
||||
fmt::BasicWriter<wchar_t>::PrepareFilledBuffer(
|
||||
unsigned size, const AlignSpec &spec, char sign);
|
||||
unsigned size, const AlignSpec<wchar_t> &spec, char sign);
|
||||
|
||||
template void fmt::BasicFormatter<wchar_t>::ReportError(
|
||||
const wchar_t *s, StringRef message) const;
|
||||
|
||||
Reference in New Issue
Block a user