-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Open
Labels
clang-formatenhancementImproving things as opposed to bug fixing, e.g. new or missing featureImproving things as opposed to bug fixing, e.g. new or missing feature
Description
To separate a constructor's member initializer list from its body, I'd like to use this style:
// short, all in one line, currently possible.
MyClass::MyClass(int val): val{val} {
// body
}
// member initializers don't fit on one line.
// separate initializers from body by putting
// brace on new line, currently not possible.
MyClass::MyClass(int someValue, int anotherValue):
some_value{some_value}, another_value{another_value}
{
// body
}
// multi-line arguments, but inline initializers.
// currently possible.
MyClass::MyClass(
int argumentWithVeryDetailedName
): val{argumentWithVeryDetailedName} {
// body
}
// both multi-line arguments and multi-line initializers.
// as before, the brace on a new line is not possible.
MyClass::MyCLass(
int argumentWithVeryDetailedName
):
fieldWithVeryDetailedName{argumentWithVeryDetailedName}
{
// body
}So, the { should be on a new line if and only the member initializers are not inline. Currently, clang-format always puts it at the end of the line of the last initializer.
wowonline, maguerrieri, ollpu, ayles, L0PiTaL and 7 more
Metadata
Metadata
Assignees
Labels
clang-formatenhancementImproving things as opposed to bug fixing, e.g. new or missing featureImproving things as opposed to bug fixing, e.g. new or missing feature