Clang-format output with lambda as default parameter value

Viewed 46

The clang-format output for function declarations seems off when the default value for a parameter is a lambda function. See the following example:

 void Sample(const TString& name,
            const Type type,
            const int color,
            VetoFunction&& veto);

void Sample(const TString& name,
            const Type type,
            const int color,
            VetoFunction&& veto = "AVeryLongDefaultNameSimilarToLambdaLength");

void Sample(
    const TString& name,
    const Type type,
    const int color,
    VetoFunction&& veto = [](const Category&) { return false; });

while in the last case I would like to obtain (no linebreak, and parameter alignment after open parenthesis, similar to the first two cases):

void Sample(const TString& name,
            const Type type,
            const int color,
            VetoFunction&& veto = [](const Category&) { return false; });

Are there specific flags to tune to achieve the desired output ?

I am using Ubuntu clang-format version 13.0.0-2, with a .clang-format file:

BasedOnStyle: LLVM
Standard: Cpp11
ColumnLimit: 80
AlignAfterOpenBracket: Align
AllowAllParametersOfDeclarationOnNextLine: false
AllowAllArgumentsOnNextLine: false
ExperimentalAutoDetectBinPacking: false
BinPackParameters: false
BinPackArguments: false
0 Answers
Related