improper indention for c++ lambda in visual studio when auto formatting code

孟轩 郝 16 Reputation points
2023-01-16T07:36:40.5733333+00:00

I have a function "func" which takes another function as its parameter.

If I define a function with more than one line using lambda expression when calling "func", the auto formatting (ctrl+k,ctrl+d) seems to get confused.

This is what I think the supposed format:

supposed format

And this is the result using auto format (ctrl+k,ctrl+d):

auto formatting

The alignment of the line "int b=1;" and "return a+b" gets weird.

I'm wondering if this a buf of visual studio or it has something to do with my settings.

Thanks.

Developer technologies | C++
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.