☰
  • 首页
  • 规则分类
  • 项目介绍
search
•••

不应使用多余的 inline 关键字

6.3.3 ID_inlineRedundant
目录 › next › previous

在类定义中实现的函数、由 constexpr 关键字限定的函数已是内联函数,不需要显式声明 inline 关键字。

示例:

struct T {
    inline int foo() {  // Non-compliant, ‘inline’ is redundant
        return 1;
    }
};

inline constexpr int bar() {  // Non-compliant, ‘inline’ is redundant
    return 0;
}

例中 inline 关键字均是多余的,应保持代码简洁,去掉多余的关键字。

依据

ISO/IEC 14882:2003 7.1.2(3) ISO/IEC 14882:2011 7.1.2(3) ISO/IEC 14882:2011 7.1.5(2)
Copyright©2024 360 Security Technology Inc., Licensed under the Apache-2.0 license.