Fix printing of numbers
Previsouly, this template was used for printing "everything" that could
be printed by iostream's operator<<. This has worked well for strings
and int/uint, but it will break when trying to print out bits such as
uint8_t or int8_t, which are type aliases to signed/unsigned char.
Because we want these numbers to be printed as decimal *numbers* instead
of *characters*, fix this by using the std::to_string helper.
Change-Id: I430b4b640cbed2936a38d73261b31df6abf42b6e
diff --git a/src/utils.cpp b/src/utils.cpp
index 7f93d27..6555ac6 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -94,12 +94,15 @@
return data.m_value;
}
+ std::string operator()(const std::string& data) const
+ {
+ return data;
+ }
+
template <typename T>
std::string operator()(const T& data) const
{
- std::stringstream stream;
- stream << data;
- return stream.str();
+ return std::to_string(data);
}
};