小编Ple*_*rts的帖子

长函数调用的可读性

我一直在编写使用函数调用的代码,这些函数调用非常长并且通常超过80个字符.通常我会像这样拆分这些函数调用:

LongFunctionName(first_argument,
                 another_argument,
                 finally_last_argument);
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试将它放入if语句时,它看起来很奇怪,主要是因为它变得不太清楚它与之比较的值是什么:

if(LongFunctionName(first_argument,
                    another_argument,
                    finally_last_argument) != value_compared_to)
{
    // stuff to be called
}
Run Code Online (Sandbox Code Playgroud)

您如何将此语句格式化为更易读并且适合80个字符?

c++ readability

2
推荐指数
1
解决办法
616
查看次数

标签 统计

c++ ×1

readability ×1