There is no good way to do what you want. C and C ++ are simply non-line-oriented languages. There is no larger unit, such as a “line of code” or anything else, as well as call chains combined anyway.
In C ++, the expression "a <b <c <d" is exactly equivalent to three separate calls to the <<operator, like this:
t1 = a;
t2 = t1.operator<<(b);
t3 = t2.operator<<(c);
t4 = t3.operator<<(d);
Why C ++ ostreams uses endl as an explicit end-of-line marker; there simply is no decent way to do it differently.
source
share