C++ setiosflags 函数操纵器 - 未确定的缩进

C++ setiosflags function manipulator - undetermined indentation

我正在学习 C++,我专注于 cout 操纵器函数。

通过 运行 下面的代码,我在包含 Gauthier.

的第二行中得到一个缩进
#include <iostream>
#include <iomanip>

int main()
{
    std::cout << std::setw(10) << std::setiosflags(std::ios::left)
        << "Mathieu\n"
        << "Gauthier\n"
        << "Paul\n"
        << "Louis\n"
        << "Pierre\n"
        << std::endl;
    return 0;
}

谁能给我解释一下这是怎么回事? 为什么 Gauthier 是缩进的而其他名字不是?

Mathieu
  Gauthier
Paul
Louis
Pierre

Program ended with exit code: 0

std::ios::left 告诉在右边添加填充字符,即它向第一个字符串添加几个字符,所以 "Mathieu\n"“变成”"Mathieu\n "。末尾有换行符 ('\n'),因此添加的空格将移至下一行 (Gauthier)。所以这不是第二行的缩进,那些是第一行的尾随字符。