, "< . , ( ) .
Next, we define a function and a macro that converts your object to a string c, which can be used in the printf function:
template <typename T> std::string string_repr(T myVar)
{
std::stringstream ss;
ss << myVar;
return ss.str();
}
Next, we have a macro that encapsulates the above function, converting std :: string to string c:
#define c_repr(_myVar) (string_repr(_myVar).c_str())
Name it as follows:
printf("prevXfm = %s newXfm = %s\n", c_repr(prevXfm), c_repr(newXfm));
Any class can be created to work with this macro if it implements "<<", just like any Python class can implement its own repr () method.
source
share