aboutsummaryrefslogtreecommitdiff
path: root/src/tinyformat.h
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2017-10-29 11:13:44 +0800
committerfanquake <fanquake@gmail.com>2017-10-29 21:12:12 +0800
commit60b98f8e145617e9e50a2eb7f3181953e1e8c424 (patch)
tree538c540f75a15082d33d74db2de480095ca1e61f /src/tinyformat.h
parentba216b5fa63e7e6cae847d1e3621f5c54840f898 (diff)
[Util] Update tinyformat.h
Updates `tinyformat.h` to commit c42f/tinyformat@689695c upstream.
Diffstat (limited to 'src/tinyformat.h')
-rw-r--r--src/tinyformat.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/tinyformat.h b/src/tinyformat.h
index 2e453e56bb..d34cfaa94f 100644
--- a/src/tinyformat.h
+++ b/src/tinyformat.h
@@ -495,7 +495,11 @@ namespace detail {
class FormatArg
{
public:
- FormatArg() {}
+ FormatArg()
+ : m_value(nullptr),
+ m_formatImpl(nullptr),
+ m_toIntImpl(nullptr)
+ { }
template<typename T>
explicit FormatArg(const T& value)
@@ -507,11 +511,15 @@ class FormatArg
void format(std::ostream& out, const char* fmtBegin,
const char* fmtEnd, int ntrunc) const
{
+ assert(m_value);
+ assert(m_formatImpl);
m_formatImpl(out, fmtBegin, fmtEnd, ntrunc, m_value);
}
int toInt() const
{
+ assert(m_value);
+ assert(m_toIntImpl);
return m_toIntImpl(m_value);
}
@@ -712,23 +720,27 @@ inline const char* streamStateFromFormat(std::ostream& out, bool& spacePadPositi
break;
case 'X':
out.setf(std::ios::uppercase);
+ // Falls through
case 'x': case 'p':
out.setf(std::ios::hex, std::ios::basefield);
intConversion = true;
break;
case 'E':
out.setf(std::ios::uppercase);
+ // Falls through
case 'e':
out.setf(std::ios::scientific, std::ios::floatfield);
out.setf(std::ios::dec, std::ios::basefield);
break;
case 'F':
out.setf(std::ios::uppercase);
+ // Falls through
case 'f':
out.setf(std::ios::fixed, std::ios::floatfield);
break;
case 'G':
out.setf(std::ios::uppercase);
+ // Falls through
case 'g':
out.setf(std::ios::dec, std::ios::basefield);
// As in boost::format, let stream decide float format.