@@ -909,7 +909,7 @@ static void compilePrecedence2(Token *&tok, AST_state& state)
909909 }
910910 compileBinOp (tok, state, compileScope);
911911 } else if (tok->str () == " [" ) {
912- if (state.cpp && isPrefixUnary (tok, state.cpp ) && Token::Match (tok->link (), " ] (|{" )) { // Lambda
912+ if (state.cpp && isPrefixUnary (tok, state.cpp ) && Token::Match (tok->link (), " ] (|{|< " )) { // Lambda
913913 // What we do here:
914914 // - Nest the round bracket under the square bracket.
915915 // - Nest what follows the lambda (if anything) with the lambda opening [
@@ -926,8 +926,10 @@ static void compilePrecedence2(Token *&tok, AST_state& state)
926926 }
927927 }
928928
929- if (Token::simpleMatch (squareBracket->link (), " ] (" )) {
930- Token* const roundBracket = squareBracket->link ()->next ();
929+ const bool hasTemplateArg = Token::simpleMatch (squareBracket->link (), " ] <" ) &&
930+ Token::simpleMatch (squareBracket->link ()->next ()->link (), " > (" );
931+ if (Token::simpleMatch (squareBracket->link (), " ] (" ) || hasTemplateArg) {
932+ Token* const roundBracket = hasTemplateArg ? squareBracket->link ()->next ()->link ()->next () : squareBracket->link ()->next ();
931933 Token* curlyBracket = roundBracket->link ()->next ();
932934 while (Token::Match (curlyBracket, " mutable|const|constexpr|consteval" ))
933935 curlyBracket = curlyBracket->next ();
0 commit comments