Oct 13
This can be used as string(“bob”) + toStr(5) without declaring the type, presuming that the type can correctly be inferred by the compiler. Obviously, T must support operator<<.
template <class T>
static inline std::string toStr(T v)
{
std::stringstream s;
s << v;
return s.str();
}
Share on Facebook
Leave a Reply
You must be logged in to post a comment.

Recent Comments