You can use a workaround:
boost::format header("%+3d"); // Add "+" when is not negative
This will lead to the following conclusion:
-1 -1 +0
+0 +0 +0
And also you can use Eigen::IOFormatcolors to set the delimiters as follows: (especially useful if elements have a different number of digits)
boost::format header("%3d");
IOFormat Fmt(3, 0, "\t", "\n", "", "");
cout << header % foo[i].transpose().format(Fmt) << endl;
:
-1 -1 0
0 0 0
:
int main(){
vector<Vector3i> foo; Vector3i bar;
bar << -1,-1,0; foo.push_back(bar);
bar << 0, 0,0; foo.push_back(bar);
boost::format header("%+3d");
IOFormat Fmt(3, 0, "\t", "\n", "", "");
for (int i = 0; i < 2; ++i)
cout << header % foo[i].transpose().format(Fmt) << endl;
return 0;
}
:
-1 -1 +0
+0 +0 +0