The*_*ing 1 c++ c++03 clang-format
当我使用 clang 来格式化我的 C++ 代码时,我遇到了一个问题:
priority_queue<int, vector<int>, greater<int> > q;
Run Code Online (Sandbox Code Playgroud)
将自动格式化为:
priority_queue<int, vector<int>, greater<int>> q;
Run Code Online (Sandbox Code Playgroud)
两个单独的 '>' 将被格式化为一个移位 >>。
那么我应该如何配置.clang-format文件来避免这种情况呢?
您可以使用标准选项。您需要 C++03 选项(包括 C++98),因为这会>在模板中格式化 double以在它们之间包含一个空格。
Standard: Cpp03
Run Code Online (Sandbox Code Playgroud)
您甚至可以Auto改用,以便clang-format可以自动检测使用的 C++ 版本。