Description
The default implementation of the template stringify in stout always copies its argument,
template <typename T> std::string stringify(T t)
For most types implementing a dedicated stringify we restrict T to some const ref with the exception of the specialization for bool,
template <> std::string stringify(const bool& b)
Copying by default is bad since it requires T to be copyable without stringify actually requiring this. It also likely leads to bad performance.
It appears switching to e.g.,
template <typename T> std::string stringify(const T& t)
and adjusting the bool specialization would be a general improvement.
This issue was first detected by Coverity in CID 727974 way back on 2012-09-21.
Attachments
Issue Links
- is related to
-
MESOS-2280 stout stringify sometimes requires both T and const T& overloads defined to work
- Open