Sometimes you will want to compose a string and justify all of that.
This is where std::stringstream comes in handy.
1 2 3 4 5 6 7 8 9 10
// A name
auto surname = "Dupain-Cheng";
auto given_name = "Marinette";
// Now, to compose the name
std::ostringstream ss;
ss << surname << ", " << givenname;
// And now to output it into a left-justified 30-character wide (but no more!) space:
std::cout << "[" << std::left << std::setw( 30 ) << ss.str().substr( 30 ) << "]\n";