mirror of
https://github.com/fmtlib/fmt.git
synced 2025-01-07 13:20:05 +00:00
Give an error if fill is not convertible to Char in StrFormatSpec
This commit is contained in:
parent
d8a3b74664
commit
4d521064cf
14
format.h
14
format.h
@ -1305,16 +1305,19 @@ class IntFormatSpec : public SpecT {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// A string format specifier.
|
// A string format specifier.
|
||||||
template <typename T>
|
template <typename Char>
|
||||||
class StrFormatSpec : public AlignSpec {
|
class StrFormatSpec : public AlignSpec {
|
||||||
private:
|
private:
|
||||||
const T *str_;
|
const Char *str_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StrFormatSpec(const T *str, unsigned width, wchar_t fill)
|
template <typename FillChar>
|
||||||
: AlignSpec(width, fill), str_(str) {}
|
StrFormatSpec(const Char *str, unsigned width, FillChar fill)
|
||||||
|
: AlignSpec(width, fill), str_(str) {
|
||||||
|
internal::CharTraits<Char>::convert(FillChar());
|
||||||
|
}
|
||||||
|
|
||||||
const T *str() const { return str_; }
|
const Char *str() const { return str_; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1930,7 +1933,6 @@ class BasicWriter {
|
|||||||
template <typename StrChar>
|
template <typename StrChar>
|
||||||
BasicWriter &operator<<(const StrFormatSpec<StrChar> &spec) {
|
BasicWriter &operator<<(const StrFormatSpec<StrChar> &spec) {
|
||||||
const StrChar *s = spec.str();
|
const StrChar *s = spec.str();
|
||||||
// TODO: error if fill is not convertible to Char
|
|
||||||
write_str(s, std::char_traits<Char>::length(s), spec);
|
write_str(s, std::char_traits<Char>::length(s), spec);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user