Discussion: Cpp11BracedListStyle option in clang-format
Cpp11BracedListStyle: true
Do you agree with adding the above line to .clang-format
? It causes C++11 braced lists to be formatted exactly like function calls would be formatted in their place. Example:
std::vector<int> x{1, 2, 3, 4}; // with Cpp11BracedListStyle: true
std::vector<int> x{ 1, 2, 3, 4 }; // with Cpp11BracedListStyle: false (currently default)
Adding this setting now has probably low impact, because this form of initialization is not used a lot in the codebase. However, we may see it more widely used in the future:
// currently:
std::vector<std::string> lwyu_cmd;
lwyu_cmd.push_back("ldd");
lwyu_cmd.push_back("-u");
lwyu_cmd.push_back("-r");
lwyu_cmd.push_back(runCmd);
// future:
std::vector<std::string> const lwyu_cmd{"ldd", "-u", "-r", runCmd};
Especially in constructors, the setting improves readability, because the {
is less likely confused with the start of the function body:
FooBar::FooBar(std::string foo, std::string bar)
: Foo{std::move(foo)}
, Bar{std::move(bar)}
{
}
Edited by Daniel Pfeifer