In a C++ code I have a matrix of double variables which I print out. However because all of them have different number of digits, the output format is destroyed. One solutio
There is a way using i/o manipulators, but I find it unwieldy. I would just write a function like this:
template std::string RightAligned(int size, const T & val) { std::string x = boost::lexical_cast(val); if (x.size() < size) x = std::string(size - x.size(), ' ') + x; return x; }