如何使用 astyle 在 C++ 方法中格式化左大括号?

Kok*_*kos 5 c++ astyle

将函数的左大括号移到下一行是一种常见做法。如何使用 astyle(代码美化器)在类方法中应用它?

例子:

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

修改后的版本应该是:

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

我所有的尝试都只适用于全局函数。

gio*_*ele 2

--style=kr / -A3和option都--style=linux / -A8应该适用于类方法。

来自文档:

括号从命名空间、类和函数定义中断开。括号附加到函数内的语句。