How to format opening curly braces in C ++ methods using astil?

A common practice is to move the parenthesis opening function to the next line. How to apply this in a class beastifier class method?

Example:

// this is an initial C++ code class Class { public: static int foo(bool x) { if (x) { return 42; } else { return 0; } } }; 

the modified version should be:

 class Class { public: static int foo(bool x) { // this brace in next line if (x) { return 42; } else { return 0; } } }; 

All my attempts work only for global functions.

+4
source share
3 answers

The parameter --style=kr / -A3 --style=linux / -A8 and --style=linux / -A8 should also apply to class methods.

From the docs:

Brackets are copied from namespace, class, and function definitions. The brackets are attached to the operators inside the function.

+1
source

This thing really depends on the preferences and preferences of his team. Most IDEs follow the brackets that you specified in the first example. They also use colored fillers to indicate the starting bracket and ending bracket. If you click on the final shape, it will also color its initial shape.

0
source

I can confirm that --style=ansi does this in the current releases of AStyle (here v2.03).

0
source

Source: https://habr.com/ru/post/1393603/


All Articles