是的,Ubuntu 上的 GCC 是支持 C++11 的,但支持程度取决于你安装的 GCC 版本。
gcc --version
g++ --version
即使 GCC 支持 C++11,也需要手动开启标准:
g++ -std=c++11 test.cpp -o test
较新版本也可以写:
g++ -std=c++14 test.cpp -o test
g++ -std=c++17 test.cpp -o test
可以升级:
sudo apt update
sudo apt install g++-11
然后指定版本编译:
g++-11 -std=c++11 test.cpp -o test
如果你愿意,可以告诉我你的 Ubuntu 版本 和 gcc --version 输出,我可以帮你确认是否可以直接用 C++11。