Skip to content
This repository was archived by the owner on Nov 28, 2019. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/tinyformat.h
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,11 @@ namespace detail {
class FormatArg
{
public:
FormatArg() {}
FormatArg()
: m_value(nullptr),
m_formatImpl(nullptr),
m_toIntImpl(nullptr)
{ }

template<typename T>
FormatArg(const T& value)
Expand All @@ -500,11 +504,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);
}

Expand Down Expand Up @@ -705,23 +713,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.
Expand Down