C++ library usage fix: snprintf() may or may not be in std::

This commit is contained in:
Pavel Kirienko
2014-04-02 13:53:39 +04:00
parent cdd0ff3a28
commit 9e91cd1e7c
5 changed files with 16 additions and 11 deletions
+4 -2
View File
@@ -204,7 +204,8 @@ template <typename Stream, typename D>
inline Stream& operator<<(Stream& s, DurationBase<D> d)
{
char buf[8];
std::snprintf(buf, sizeof(buf), "%06lu", static_cast<unsigned long>(std::abs(d.toUSec() % 1000000L)));
using namespace std; // For snprintf()
snprintf(buf, sizeof(buf), "%06lu", static_cast<unsigned long>(std::abs(d.toUSec() % 1000000L)));
if (d.isNegative())
{
s << '-';
@@ -217,7 +218,8 @@ template <typename Stream, typename T, typename D>
inline Stream& operator<<(Stream& s, TimeBase<T, D> t)
{
char buf[8];
std::snprintf(buf, sizeof(buf), "%06lu", static_cast<unsigned long>(t.toUSec() % 1000000L));
using namespace std; // For snprintf()
snprintf(buf, sizeof(buf), "%06lu", static_cast<unsigned long>(t.toUSec() % 1000000L));
s << (t.toUSec() / 1000000L) << '.' << buf;
return s;
}